public ActionResult GetLocations() { List <LocationUpdateModel> models = new List <LocationUpdateModel>(); var locations = LocationBlo.GetLocations2(AppDomain.CurrentDomain.BaseDirectory); foreach (var item in locations) { var location = new LocationUpdateModel { Id = item.Id, Name = item.Name, Address = item.Address, PhoneNumbers = item.PhoneNumbers, FaxNumbers = item.FaxNumbers, LocationType = item.LocationType, Specialists = LocationDto.SpecialistsToString(item.Specialists), Rating = item.Rating.ToString(CultureInfo.CurrentCulture), Area1 = item.Area1, Area2 = item.Area2, Latitude = item.Latitude, Longitude = item.Longitude }; models.Add(location); } return(View(models)); }
public ActionResult Details(string id) { var model = new LocationUpdateModel(); var locations = LocationBlo.GetLocations2(AppDomain.CurrentDomain.BaseDirectory); var exists = locations.Where(x => x.Id == id).ToList(); if (exists.Count > 0) { var item = exists[0]; model = new LocationUpdateModel { Id = item.Id, Name = item.Name, Address = item.Address, PhoneNumbers = item.PhoneNumbers, FaxNumbers = item.FaxNumbers, LocationType = item.LocationType, Specialists = LocationDto.SpecialistsToString(item.Specialists), Rating = item.Rating.ToString(CultureInfo.CurrentCulture), Area1 = item.Area1, Area2 = item.Area2, Latitude = item.Latitude, Longitude = item.Longitude }; } return(View(model)); }
public ActionResult Home(string tab, string tab2, string tab3) { var model = new HomeViewModel() { Items = new List <HomepageViewModel>() }; string path = AppDomain.CurrentDomain.BaseDirectory; var locations = LocationBlo.GetLocations2(path); switch (tab) { case "rating": model.TabValue = "rating"; model.ListTitle = "Danh sách 15 bệnh viện nổi bật theo đánh giá của người dùng"; DisplayForRating(locations, model.Items); break; case "area1": model.TabValue = "area1"; model.ListTitle = "Danh sách các bệnh viện nổi bật theo tỉnh, thành phố"; model.TabValueLvl2 = tab2; DisplayForArea1(locations, tab2, model.Items); break; case "area2": model.TabValue = "area2"; model.ListTitle = "Danh sách các bệnh viện nổi bật theo quận, huyện"; model.TabValueLvl2 = tab2; model.TabValueLvl3 = tab3; DisplayForArea2(locations, tab2, tab3, model.Items); break; case "specialist": model.TabValue = "specialist"; model.ListTitle = "Danh sách các bệnh viện nổi bật theo chuyên khoa"; model.TabValueLvl2 = tab2; DisplayForSpecialist(locations, tab2, model.Items); break; default: model.TabValue = "rating"; model.ListTitle = "Danh sách 15 bệnh viện nổi bật theo đánh giá của người dùng"; DisplayForRating(locations, model.Items); break; } return(View(model)); }
private void DisplayForArea2(List <LocationDto> locations, string area1, string area2, List <HomepageViewModel> items) { if (locations == null || items == null) { return; } List <LocationDto> exists; if (string.IsNullOrEmpty(area1)) { exists = locations.Where(x => x.Area1 == "Hà Nội" && x.Area2 == "Cầu Giấy").ToList(); } else { exists = locations.Where(x => x.Area1 == area1 && x.Area2 == area2).ToList(); } LocationBlo.Sort(exists, SortOption.Rating, false); int count = 0; foreach (var location in exists) { HomepageViewModel hvm = new HomepageViewModel { Id = location.Id, Name = location.Name, Rating = location.Rating, Area1 = location.Area1, Area2 = location.Area2 }; if (location.Specialists.Count > 0) { hvm.Specialist = location.Specialists[0]; } items.Add(hvm); count++; if (count == 15) { break; } } }
private void DisplayForSpecialist(List <LocationDto> locations, string specialist, List <HomepageViewModel> items) { if (locations == null || items == null) { return; } List <LocationDto> exists; if (string.IsNullOrEmpty(specialist)) { exists = locations.Where(x => x.Exists("Chấn thương chỉnh hình")).ToList(); } else { exists = locations.Where(x => x.Exists(specialist)).ToList(); } LocationBlo.Sort(exists, SortOption.Rating, false); int count = 0; foreach (var location in exists) { HomepageViewModel hvm = new HomepageViewModel { Id = location.Id, Name = location.Name, Rating = location.Rating, Area1 = location.Area1, Area2 = location.Area2 }; if (location.Specialists.Count > 0) { hvm.Specialist = location.Specialists[0]; } items.Add(hvm); count++; if (count == 15) { break; } } }
public ActionResult ViewOnMaps(string id, string txtSearch, string txtPlaceId) { ViewOnMapsViewModel model = new ViewOnMapsViewModel(); if (!string.IsNullOrEmpty(id)) { string path = AppDomain.CurrentDomain.BaseDirectory; List <LocationDto> locations = LocationBlo.GetLocations2(path); model.Id = id; var results = LocationBlo.Search(locations, SearchOption.Id, id); if (results.Count > 0) { model.UrlSource = "https://www.google.com/maps/embed/v1/place?" + "key=AIzaSyCXu7DK2qiuIyb1tmiHUNemOwY3DTfTP18" + "&q=" + results[0].Address.Replace(" ", "+") + "&language=vi"; } } else { if (!string.IsNullOrEmpty(txtSearch)) { model.UrlSource = "https://www.google.com/maps/embed/v1/place?" + "key=AIzaSyCXu7DK2qiuIyb1tmiHUNemOwY3DTfTP18" + "&q=" + txtSearch + "&language=vi"; model.SearchValue = txtSearch; if (!string.IsNullOrEmpty(txtPlaceId)) { model.LocationDetails = new LocationDetailsViewModel(); } } else { model.UrlSource = "https://www.google.com/maps/embed/v1/place?" + "key=AIzaSyCXu7DK2qiuIyb1tmiHUNemOwY3DTfTP18" + "&q=Ho+Chi+Minh,Vietname" + "&language=vi"; } } return(View(model)); }
public ActionResult Create(LocationUpdateModel model) { if (model == null) { model = new LocationUpdateModel(); } else { if (!string.IsNullOrEmpty(model.Name)) { var item = model; var location = new LocationDto { Id = item.Id, Name = item.Name, Address = item.Address, PhoneNumbers = item.PhoneNumbers, FaxNumbers = item.FaxNumbers, LocationType = item.LocationType, Specialists = LocationDto.ParseSpecialists(item.Specialists), Rating = 0, Area1 = item.Area1, Area2 = item.Area2, Latitude = item.Latitude, Longitude = item.Longitude }; double temp; if (double.TryParse(item.Rating, out temp)) { location.Rating = temp; } LocationBlo.Add(AppDomain.CurrentDomain.BaseDirectory, location); } } return(View(model)); }
private void DisplayForRating(List <LocationDto> locations, List <HomepageViewModel> items) { if (locations == null || items == null) { return; } LocationBlo.Sort(locations, SortOption.Rating, false); int count = 0; foreach (var location in locations) { HomepageViewModel hvm = new HomepageViewModel { Id = location.Id, Name = location.Name, Rating = location.Rating, Area1 = location.Area1, Area2 = location.Area2 }; if (location.Specialists.Count > 0) { hvm.Specialist = location.Specialists[0]; } items.Add(hvm); count++; if (count == 15) { break; } } }
public ActionResult Search(string txtSearch, string ddlSearchOptions) { var model = new SearchViewModel { SearchValue = txtSearch, Locations = new List <SearchLocationViewModel>() }; string path = AppDomain.CurrentDomain.BaseDirectory; List <LocationDto> locations = LocationBlo.GetLocations2(path); if (!string.IsNullOrEmpty(txtSearch)) { switch (ddlSearchOptions) { case "Name": locations = LocationBlo.Search(locations, SearchOption.Name, txtSearch); break; case "Specialist": locations = LocationBlo.Search(locations, SearchOption.Specialist, txtSearch); break; case "Address": locations = LocationBlo.Search(locations, SearchOption.Address, txtSearch); break; } } LocationBlo.Sort(locations, SortOption.SpectialistAndName, true); if (locations != null) { foreach (var location in locations) { SearchLocationViewModel slvm = new SearchLocationViewModel { Id = location.Id, Name = location.Name, Address = location.Address, Rating = location.Rating }; if (location.Specialists.Count > 1) { for (int i = 0; i < location.Specialists.Count - 1; i++) { slvm.Specialists += location.Specialists[i] + "; "; } slvm.Specialists += location.Specialists[location.Specialists.Count - 1]; } else if (location.Specialists.Count == 1) { slvm.Specialists = location.Specialists[0]; } model.Locations.Add(slvm); } } return(View(model)); }
public ActionResult Edit(LocationUpdateModel model, string id) { if (model == null) { model = new LocationUpdateModel(); } if (!string.IsNullOrEmpty(id)) { var locations = LocationBlo.GetLocations2(AppDomain.CurrentDomain.BaseDirectory); var exists = locations.Where(x => x.Id == id).ToList(); if (exists.Count > 0) { var item = exists[0]; model = new LocationUpdateModel { Id = item.Id, Name = item.Name, Address = item.Address, PhoneNumbers = item.PhoneNumbers, FaxNumbers = item.FaxNumbers, LocationType = item.LocationType, Specialists = LocationDto.SpecialistsToString(item.Specialists), Rating = item.Rating.ToString(CultureInfo.CurrentCulture), Area1 = item.Area1, Area2 = item.Area2, Latitude = item.Latitude, Longitude = item.Longitude }; } } else { if (!string.IsNullOrEmpty(model.Name)) { var item = model; var location = new LocationDto { Id = item.Id, Name = item.Name, Address = item.Address, PhoneNumbers = item.PhoneNumbers, FaxNumbers = item.FaxNumbers, LocationType = item.LocationType, Specialists = LocationDto.ParseSpecialists(item.Specialists), Rating = 0, Area1 = item.Area1, Area2 = item.Area2, Latitude = item.Latitude, Longitude = item.Longitude }; double temp; if (double.TryParse(item.Rating, out temp)) { location.Rating = temp; } LocationBlo.Update(AppDomain.CurrentDomain.BaseDirectory, location); } } return(View(model)); }