private BulkUploadResponse BulkUpload_OfJson(IEnumerable <TModel> data, eOverwriteMethod OverwriteMethod, IEnumerable <string> fieldsToUpload) { FlatModel FlatModel = PepperiFlatSerializer.MapDataToFlatModel(data, fieldsToUpload, "''"); string RequestUri = string.Format("bulk/{0}/json", ResourceName); Dictionary <string, string> dicQueryStringParameters = new Dictionary <string, string>(); dicQueryStringParameters.Add("overwrite", OverwriteMethod.ToString()); string postBody = PepperiJsonSerializer.Serialize(FlatModel); //null values are not serialzied. string contentType = "application/json"; string accept = "application/json"; PepperiHttpClient PepperiHttpClient = new PepperiHttpClient(this.Authentication, this.Logger); PepperiHttpClientResponse PepperiHttpClientResponse = PepperiHttpClient.PostStringContent( ApiBaseUri, RequestUri, dicQueryStringParameters, postBody, contentType, accept ); PepperiHttpClient.HandleError(PepperiHttpClientResponse); BulkUploadResponse result = PepperiJsonSerializer.DeserializeOne <BulkUploadResponse>(PepperiHttpClientResponse.Body); return(result); }
public string UpdateFlat(FlatModel flat) { Mapper.CreateMap <FlatModel, Flat>().ForMember(dest => dest.FlatPLCs, sec => sec.Ignore()); Flat fl = Mapper.Map <FlatModel, Flat>(flat); int i = fservice.EditFlat(fl); FlatPLCService fpservice = new FlatPLCService(); var model = fpservice.GetFlatPLCListByFlatID(fl.FlatID); foreach (var ft in model) { FlatPLC md = new FlatPLC(); md.FlatPLCID = ft.FlatPLCID; int ii = fpservice.DeleteFlatPLC(md); } foreach (string st in flat.FlatPLCs) { if (st != "0") { FlatPLC fpm = new FlatPLC(); fpm.FlatID = fl.FlatID; fpm.PLCID = Convert.ToInt32(st); int ii = fpservice.AddFlatPLC(fpm); } } return(i.ToString()); }
private BulkUploadResponse BulkUploadOfZip(IEnumerable <TModel> data, eOverwriteMethod OverwriteMethod, IEnumerable <string> fieldsToUpload, string FilePathToStoreZipFile, string SubTypeID = null) { FlatModel FlatModel = PepperiFlatSerializer.MapDataToFlatModel(data, fieldsToUpload, "''"); string CsvFileAsString = PepperiFlatSerializer.FlatModelToCsv(FlatModel); byte[] CsvFileAsZipInUTF8 = PepperiFlatSerializer.UTF8StringToZip(CsvFileAsString, FilePathToStoreZipFile); BulkUploadResponse result = BulkUploadOfZip(CsvFileAsZipInUTF8, OverwriteMethod, SubTypeID); return(result); }
void NPanel_MouseDoubleClick(object sender, MouseEventArgs e) { if (SelectedComponent != null) { FlatModel model = SelectedComponent.GetFlatModel(); txtText.Left = (int)model.StartPoint.X; txtText.Width = (int)(model.EndPoint.X - model.StartPoint.X); txtText.Top = (int)model.StartPoint.Y; txtText.Height = (int)(model.EndPoint.Y - model.StartPoint.Y); txtText.Text = model.Text; txtText.Visible = true; txtText.Focus(); } }
public FlatViewModel(FlatModel flatModel) { Area = flatModel.Area; FloorNumber = flatModel.FloorNumber; Section = flatModel.Section; Number = flatModel.Number; if (Section == SectionType.Furniture) { SectionName = LocRes.Mebelnaya; } else if (Section == SectionType.Hospital) { SectionName = LocRes.Hospital; } OnPropertyChanged(nameof(FullFlatLocationInfo)); }
private void FillFloorsForSection(int flatsPerFloor, int startFlatNumber) { const int startFloorNumber = 2; int sectionStartFlatNumber = startFlatNumber; Dictionary <int, float> areasDict = sectionType == SectionType.Furniture ? mebelFlatAreas : hospitalFlatAreas; for (int floorNumber = startFloorNumber; floorNumber <= StaticsProvider.TotalFloorsCount; floorNumber++) { var floorModel = new FloorModel { FloorNumber = floorNumber, Section = sectionType, MinFlatNumber = sectionStartFlatNumber + (floorNumber - startFloorNumber) * flatsPerFloor, }; floorModel.MaxFlatNumber = floorModel.MinFlatNumber + flatsPerFloor - 1; var floorViewModel = new FloorViewModel(floorModel); var flats = new List <FlatViewModel>(); for (int flatIndex = 1; flatIndex < flatsPerFloor + 1; flatIndex++) { var flatModel = new FlatModel { Area = areasDict[flatIndex], FloorNumber = floorViewModel.FloorNumber, Number = startFlatNumber, Section = sectionType }; var flat = new FlatViewModel(flatModel); flats.Add(flat); startFlatNumber++; } floorViewModel.PopulateFlats(flats); var decorator = new FloorDecoratorViewModel(floorViewModel); allFloors.Add(decorator); } allFloors.Reverse(); predicatedFloors.AddRange(allFloors); }
public string SaveFat(FlatModel flat) { Mapper.CreateMap <FlatModel, Flat>().ForMember(dsd => dsd.FlatPLCs, df => df.Ignore()); Flat fl = Mapper.Map <FlatModel, Flat>(flat); fl.CrBy = User.Identity.Name; fl.CrDate = DateTime.Now; int i = fservice.AddNewFlat(fl); FlatPLCService fpservice = new FlatPLCService(); foreach (string st in flat.FlatPLCs) { if (st != "0") { FlatPLC fpm = new FlatPLC(); fpm.FlatID = fl.FlatID; fpm.PLCID = Convert.ToInt32(st); int ii = fpservice.AddFlatPLC(fpm); } } return(i.ToString()); }
public async Task CreateRepairSetting([FromBody] FlatModel model) { var user = db.Users.Find(x => x.Login == model.login).FirstOrDefault(); if (user == null) { Response.StatusCode = 400; await Response.WriteAsync("Invalid user name"); return; } var flat = new Flat() { User = user, Square = model.square, RoomNumber = model.roomNumber, DoorNumber = model.doorNumber, Height = model.height, Address = model.address, Rooms = model.rooms, Bathroom = db.BaseSettings.Find(x => x.ID == model.bathroomID).FirstOrDefault(), Kitchen = db.BaseSettings.Find(x => x.ID == model.kitchenID).FirstOrDefault(), Additionals = new List <AdditionalsFlat>(model.additionalsID.Select(x => new AdditionalsFlat() { AdditionalOptionsID = x })) }; db.Flats.Create(flat); db.Save(); Response.StatusCode = 200; await Response.WriteAsync(JsonConvert.SerializeObject( new RepairResponseModel { FlatID = flat.ID, Cost = getRepairCost(flat.ID) })); }
private void InitiateHome() { HomeStatus StatusCurrent; bool IsCreditCurrent = false; int PriceFlatCurrent = 0; int PriceRepairCurrent = 0; if (currentYear == 2018 && currentMonth <= 5) { StatusCurrent = HomeStatus.Buying; IsCreditCurrent = true; sum = sum + Helper.IncomeByMonth * (currentMonth + 1); PriceRepairCurrent = 18000; PriceFlatCurrent = 15000; if (currentMonth == 6) { sum = sum - PriceFlatCurrent; PriceFlatCurrent = 0; } } else if (currentYear == 2018 && currentMonth <= 11) { StatusCurrent = HomeStatus.Repairing; PriceFlatCurrent = 0; PriceRepairCurrent = 18000 - (currentMonth - 5) * Helper.IncomeByMonth; sum = sum + Helper.IncomeByMonth * (currentMonth + 1) - Helper.PriceCredit; } else { StatusCurrent = HomeStatus.Profiting; sum = sum + Helper.IncomeByMonth * (currentMonth - 1) - Helper.PriceCredit - Helper.PriceRepair; } FlatModel firstHome = new FlatModel(1, StatusCurrent, IsCreditCurrent, PriceFlatCurrent, PriceRepairCurrent, 200); flats.Add(firstHome); }
private void CollectToBuyNewFlat() { if (sum < Helper.PriceFlat + Helper.MinStorage) { currentCount = 1; incomeMonth = incomeMonth + flats.Last().IncomeMonth; var currentFlat = new FlatModel() { Id = flats.Count + 1, Status = HomeStatus.Buying, PriceRepair = Helper.PriceRepair, PriceFlat = Helper.PriceFlat, IncomeMonth = Helper.IncByOne }; outputStatusStr = outputStatusStr + "B(" + currentFlat.Id + ")| "; flats.Add(currentFlat); } else { currentCount = (sum - Helper.MinStorage) / Helper.PriceFlat; for (int i = 0; i < currentCount; i++) { var currentFlat = new FlatModel() { Id = flats.Count + 1, Status = HomeStatus.Repairing, PriceRepair = Helper.PriceRepair, PriceFlat = 0, IncomeMonth = Helper.IncByOne }; sum = sum - Helper.PriceRepair; outputStatusStr = outputStatusStr + "BR(" + currentFlat.Id + ")| "; flats.Add(currentFlat); } } }
public void Delete([FromBody] FlatModel value) { new FlatService().Remove(value); }
public void Put([FromBody] FlatModel value) { new FlatService().AddOrUpdate(value); }
public string getFlatByID(int flatid) { FlatModel fl = fservice.GetFlatByID(flatid); return(Newtonsoft.Json.JsonConvert.SerializeObject(fl)); }
public override void SetFlatModel(FlatModel model) { Model.Accept(model); }
public abstract void SetFlatModel(FlatModel model);