public JsonResult SaveSvgData(BuildingSvgConfigModel model) { if (string.IsNullOrWhiteSpace(model.Svg)) { model.Svg = string.Empty; } var prevSvg = ApartmentManager.GetSvgData(model.BuildingId, model.AssetId); if (prevSvg != null) { prevSvg.Svg = model.Svg; ApartmentManager.UpdateSvgData(prevSvg); } else { var newBuildingSvg = new SvgData(); newBuildingSvg.BuildingId = model.BuildingId; newBuildingSvg.AssetId = model.AssetId; newBuildingSvg.Svg = model.Svg; newBuildingSvg.Type = 0; ApartmentManager.SaveSvgData(newBuildingSvg); } return(Json(new { Message = "Success" })); }
public ActionResult BMBuildingUploadInfo() { //guard clause if (Request.Files == null || Request.Files.Count == 0) { return(Json(false, JsonRequestBehavior.AllowGet)); } //check if request has valid keys var requestResult = BuildingRequestHelper.GetRequestResult(Request); if (!requestResult.IsValid) { return(Json(false, JsonRequestBehavior.AllowGet)); } //identify type of file uploaded ( excel or csv) bool success = false; var message = "There was a problem with the upload. Please contact administrator."; List <ApartmentViewModel> list = null; if (Request.Files[0] != null && Request.Files[0].ContentLength > 0) { var uploadedFile = Request.Files[0]; var extension = Path.GetExtension(uploadedFile.FileName); try { //TODO: the static factory causes some issue with repo dependencies //var dataSourceManager = DataSourceServiceFactory.GetService(extension); var building = _buildingRepo.GetById(requestResult.BuildingId); if (building == null) { throw new ArgumentNullException("building"); } var apartmentData = ApartmentManager.MapDataSourceToApartment(uploadedFile, requestResult.BuildingId) as List <Apartment>; if (apartmentData != null && apartmentData.Count > 0) { list = apartmentData.Select(apt => { var vm = ApartmentViewModel.CreateModel(apt); return(vm); }).ToList(); success = true; message = string.Concat("Successully uploaded ", uploadedFile.FileName); } } catch (Exception ex) { LogHelper.Error <BMBuildingController>(ex.Message, ex); success = false; } } return(Json(new { success, message, list }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetSimpleApartmentsList(int id) { var list = new List <BaseApartmentViewModel>(); list.AddRange(ApartmentManager.GetSimpleApartmentsList(id).Select(x => new BaseApartmentViewModel() { Id = x.Id, Room = x.Room })); return(Json(new { Message = "Sucess", list }, JsonRequestBehavior.AllowGet)); }
protected override void OnNavigatedTo(NavigationEventArgs e) { //this.DataContext = e.Parameter; _apartmentId = (string)e.Parameter; CoverImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/ApartmentImages/CoverImages/" + _apartmentId + "/FrontView.jpg", UriKind.Absolute)); InsideImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/ApartmentImages/InsideImages/" + _apartmentId + "/InsideView.jpg", UriKind.Absolute)); ApartmentManager myManager = new ApartmentManager(); apartments = myManager.GetAllApartmentsList(); _apartmentIdInt = Int32.Parse(_apartmentId); selectedApartment.Add(apartments[_apartmentIdInt]); }
public JsonResult BMBuildingInfo() { //check if request has valid keys var requestResult = BuildingRequestHelper.GetRequestResult(Request); if (!requestResult.IsValid) { return(Json(false, JsonRequestBehavior.AllowGet)); } bool success = false; //get the apartments registered on db for the building var apartments = ApartmentManager.GetApartments(requestResult.BuildingId); List <ApartmentViewModel> list = null; if (apartments != null && apartments.Count > 0) { list = apartments.Select(apt => { var vm = ApartmentViewModel.CreateModel(apt); //identify the file assets for the apartment //var apartment = _apartmentRepo.GetById(apt.Id); var assets = MediaManager.GetApartmentMediaAssets(apt.Id); if (assets != null && assets.Count > 0) { vm.FileAssets = assets.Select(x => { return(new ApartmentAssetViewModel { MediaId = x.Id, Url = Umbraco.TypedMedia(x.Id).Url }); }).ToList <ApartmentAssetViewModel>(); } return(vm); }).ToList(); success = true; } return(Json(new { success, list }, JsonRequestBehavior.AllowGet)); }
void Awake() { instance = this; }
public JsonResult GetSvgData(BuildingSvgConfigModel model) { var data = ApartmentManager.GetSvgData(model.BuildingId, model.AssetId); return(Json(new { svgData = data })); }
public ApartmentController(FoodserviceContext context) { manager = new ApartmentManager(context); }
public ApartmentsController() { apartmentManager = new ApartmentManager(); }