public JsonResult SearchPlace(SearchPlaceViewModel model) { if (model.ServiceType == null) { model.ServiceType = ""; } if (model.PlaceName == null) { model.PlaceName = ""; } Citizen user = User.Identity.GetCitizen(); List <MedicalPlace> medicalPlaces = new List <MedicalPlace>(); if (model.ServiceType.ToUpper().Equals("ICU") || model.PlaceName.ToUpper().Equals("ICU")) { medicalPlaces = MedicalPlaceBusinessLayer.SearchCareUnitsPlace(model.Latitude, model.Longitude, model.ServiceType, model.PlaceName, model.IsDistance, model.IsCost, model.IsRate, model.IsPopularity).ToList(); } else { medicalPlaces = MedicalPlaceBusinessLayer.SearchMedicalPlace(model.Latitude, model.Longitude, model.ServiceType, model.PlaceName, model.IsDistance, model.IsCost, model.IsRate, model.IsPopularity).ToList(); } var result = medicalPlaces.Select(place => new { place.ID, placeType = place.MedicalPlaceType.Name, place.Name, place.Address, place.Phone, Photo = string.Format("data:image/png;base64,{0}", Convert.ToBase64String(place.Photo)) }).ToList(); return(Json(new { places = result })); }
public ActionResult AddMedicalPlace(MedicalPlaceViewModels model) { DAL.MedicalPlace newPlace = new DAL.MedicalPlace(); newPlace.Address = model.MedicalPlace.Address; newPlace.Description = model.MedicalPlace.Description; newPlace.Name = model.MedicalPlace.Name; newPlace.IsConfirmed = false; newPlace.OwnerID = User.Identity.GetCitizen().Id; newPlace.Phone = model.MedicalPlace.Phone; newPlace.TypeID = model.MedicalPlace.TypeID; double latitude = model.Latitude; double longitude = model.Longitude; var pointString = string.Format("POINT({0} {1})", longitude.ToString(), latitude.ToString()); var point = DbGeography.FromText(pointString); newPlace.Location = point; using (var binaryReader = new BinaryReader(model.MedicalPlace.Photo.InputStream)) { newPlace.Photo = binaryReader.ReadBytes(model.MedicalPlace.Photo.ContentLength); } using (var binaryReader = new BinaryReader(model.MedicalPlace.Permission.InputStream)) { newPlace.Permission = binaryReader.ReadBytes(model.MedicalPlace.Permission.ContentLength); } MedicalPlaceBusinessLayer.AddMedicalPlace(newPlace); return(ProfilePage(newPlace.ID)); }
public ActionResult MedicalPlace() { MedicalPlaceViewModels model = new MedicalPlaceViewModels(); ICollection <MedicalPlaceType> medicalPlaceTypes = MedicalPlaceBusinessLayer.GetAllTypes(); List <SelectListItem> dropDownList = new List <SelectListItem>(); foreach (MedicalPlaceType medicalType in medicalPlaceTypes) { dropDownList.Add(new SelectListItem { Text = medicalType.Name, Value = medicalType.ID.ToString() }); } model.MedicalPlaceTypes = dropDownList; return(View("AddMedicalPlace", model)); }
public ActionResult ProfilePage(long id) { var medicalPlace = MedicalPlaceBusinessLayer.GetMedicalPlace(id); MedicalPlaceProfileViewModel model = new MedicalPlaceProfileViewModel() { MedicalPlaceID = medicalPlace.ID, Services = new List <ServiceViewModel>(), CareUnits = new List <CareUnitViewModel>(), ServiceCategories = ServiceBusinessLayer.GetServiceCategories(), CareUnitTypes = CareUnitBusinessLayer.GetCareUnitTypes(), IsAdmin = medicalPlace.Admins.Select(m => m.Id).Contains(User.Identity.GetUserId <long>()), MedicalPlace = medicalPlace, IsCurrentPlace = Request.Cookies["placeInfo"] != null && Convert.ToInt64(Request.Cookies["placeInfo"].Values["id"]) == id?true : false, }; foreach (var service in medicalPlace.Services) { var groupedSlots = service.WorkSlots.GroupBy(slot => new { slot.StartTime, slot.EndTime }); ServiceViewModel smodel = new ServiceViewModel() { ID = service.ID, Name = service.Name, Cost = service.Cost ?? 0, Description = service.Description, CategoryID = service.CategoryID, ProviderID = service.ProviderID ?? 0, WorkSlots = new List <WorkSlotViewModel>() }; foreach (var element in groupedSlots) { WorkSlotViewModel wmodel = new WorkSlotViewModel(); wmodel.StartTime = element.Key.StartTime ?? TimeSpan.Zero; wmodel.EndTime = element.Key.EndTime ?? TimeSpan.Zero; wmodel.ServiceID = service.ID; foreach (var day in element) { switch (day.DayName) { case "Saturday": wmodel.IsSaturday = true; break; case "Sunday": wmodel.IsSunday = true; break; case "Monday": wmodel.IsMonday = true; break; case "Tuesday": wmodel.IsTuesday = true; break; case "Wednesday": wmodel.IsWednesday = true; break; case "Thursday": wmodel.IsThursday = true; break; case "Friday": wmodel.IsFriday = true; break; } } smodel.WorkSlots.Add(wmodel); } model.Services.Add(smodel); } foreach (var careunit in medicalPlace.CareUnits) { CareUnitViewModel cmodel = new CareUnitViewModel() { ID = careunit.ID, Name = careunit.Name, CareUnitTypeID = careunit.CareUnitTypeID, AvailableRoomCount = careunit.AvailableRoomCount ?? 0, Cost = careunit.Cost, ProviderID = careunit.ProviderID, Description = careunit.Description, LastUpdate = careunit.LastUpdate }; model.CareUnits.Add(cmodel); } return(View("ProfilePage", model)); }
public MedicalPlaceController(MedicalPlaceBusinessLayer medicalPlaceBusinessLayer, CareUnitBusinessLayer careUnitBusinessLayer, ServiceBusinessLayer serviceBusinessLayer) { _medicalPlaceBusinessLayer = medicalPlaceBusinessLayer; _careUnitBusinessLayer = careUnitBusinessLayer; _serviceBusinessLayer = serviceBusinessLayer; }