2024-04-04 10:17:48 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2024-04-11 11:56:08 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
2024-04-04 10:17:48 +00:00
|
|
|
|
|
|
|
|
|
namespace RealEstate
|
|
|
|
|
{
|
|
|
|
|
public class Ad
|
|
|
|
|
{
|
|
|
|
|
public int Area
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
public Category Category
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
public DateTime CreateAt
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
public string Description
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
public int Floors
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
public bool FreeOfCharge
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
public int Id
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
public string ImageUrl
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
public string LatLong
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
public int Rooms
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
public Seller Seller
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<Ad> LoadFromCsv(string filename)
|
|
|
|
|
{
|
|
|
|
|
List<Ad> lista = new List<Ad>();
|
|
|
|
|
|
2024-04-11 11:56:08 +00:00
|
|
|
|
string[] sorok = File.ReadAllLines(filename);
|
|
|
|
|
for (int i = 1; i < sorok.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
lista.Add(new Ad(sorok[i]));
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-04 10:17:48 +00:00
|
|
|
|
|
|
|
|
|
return lista;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Ad(string adatsor)
|
|
|
|
|
{
|
|
|
|
|
string[] t = adatsor.Split(';');
|
|
|
|
|
Id = int.Parse(t[0]);
|
|
|
|
|
Rooms = int.Parse(t[1]);
|
|
|
|
|
LatLong = t[2];
|
|
|
|
|
Floors = int.Parse(t[3]);
|
|
|
|
|
Area = int.Parse(t[4]);
|
|
|
|
|
Description = t[5];
|
|
|
|
|
FreeOfCharge = (t[6] == "1");
|
|
|
|
|
ImageUrl = t[7];
|
|
|
|
|
CreateAt = DateTime.Parse(t[8]);
|
|
|
|
|
|
2024-04-11 11:56:08 +00:00
|
|
|
|
Seller = new Seller(int.Parse(t[9]), t[10], t[11]);
|
|
|
|
|
Category = new Category(int.Parse(t[12]), t[13]);
|
|
|
|
|
}
|
|
|
|
|
public double DistanceTo(double lat2, double long2)
|
|
|
|
|
{
|
|
|
|
|
double lat1 = double.Parse(LatLong.Split(',')[0].Replace('.',','));
|
|
|
|
|
double long1 = double.Parse(LatLong.Split(',')[1].Replace('.',','));
|
|
|
|
|
return Math.Sqrt();
|
2024-04-04 10:17:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|