Exemple #1
0
 private void UpdateAppartment()
 {
     if (mode == Mode.Create)
     {
         var app = new Appartment()
         {
             Number      = this.Number,
             Floor       = this.Floor,
             GeneralArea = this.GeneralArea,
             LivingArea  = this.LivingArea,
             ElectricityActualCounter = this.ElectricityActualCounter,
             WaterActualCounter       = this.WaterActualCounter,
             GasActualCounter         = this.GasActualCounter,
             ElectricityPrevCounter   = this.ElectricityPrevCounter,
             WaterPrevCounter         = this.WaterPrevCounter,
             GasPrevCounter           = this.GasPrevCounter,
             SpdtBill           = this.SpdtBill,
             SpdtPayment        = this.SpdtPayment,
             ElectricityBill    = this.ElectricityBill,
             WaterBill          = this.WaterBill,
             GasBill            = this.GasBill,
             TotalBill          = this.TotalBill,
             ElectricityPayment = this.ElectricityPayment,
             WaterPayment       = this.WaterPayment,
             GasPayment         = this.GasPayment,
             TotalPayment       = this.TotalPayment,
         };
         app.AppartmentId = context.AddNewAppartment(Number, Floor, LivingArea, GeneralArea, ElectricityBill, ElectricityPayment, WaterBill, WaterPayment,
                                                     GasBill, GasPayment, SpdtBill, SpdtPayment, TotalBill + ElectricityBill + WaterBill + GasBill, TotalPayment + ElectricityPayment +
                                                     WaterPayment + GasPayment, ElectricityPrevCounter, ElectricityActualCounter, WaterPrevCounter,
                                                     WaterActualCounter, GasPrevCounter, GasActualCounter);
         parentAppartmentViewModel.Appartments.Add(app);
     }
     else
     {
         var app = parentAppartmentViewModel.Appartments.FirstOrDefault(x => x.AppartmentId == Id);
         context.UpdateAppartment(Id, Number, Floor, LivingArea, GeneralArea, ElectricityBill, ElectricityPayment, WaterBill, WaterPayment,
                                  GasBill, GasPayment, SpdtBill, SpdtPayment, TotalBill + ElectricityBill + WaterBill + GasBill, TotalPayment + ElectricityPayment +
                                  WaterPayment + GasPayment, ElectricityPrevCounter, ElectricityActualCounter, WaterPrevCounter,
                                  WaterActualCounter, GasPrevCounter, GasActualCounter);
         int i = parentAppartmentViewModel.Appartments.IndexOf(app);
         parentAppartmentViewModel.Appartments[i] = new Appartment()
         {
             AppartmentId             = Id,
             Number                   = this.Number,
             Floor                    = this.Floor,
             GeneralArea              = this.GeneralArea,
             LivingArea               = this.LivingArea,
             ElectricityActualCounter = this.ElectricityActualCounter,
             WaterActualCounter       = this.WaterActualCounter,
             GasActualCounter         = this.GasActualCounter,
             ElectricityPrevCounter   = this.ElectricityPrevCounter,
             WaterPrevCounter         = this.WaterPrevCounter,
             GasPrevCounter           = this.GasPrevCounter,
             SpdtBill                 = this.SpdtBill,
             SpdtPayment              = this.SpdtPayment,
             ElectricityBill          = this.ElectricityBill,
             WaterBill                = this.WaterBill,
             GasBill                  = this.GasBill,
             TotalBill                = this.TotalBill,
             ElectricityPayment       = this.ElectricityPayment,
             WaterPayment             = this.WaterPayment,
             GasPayment               = this.GasPayment,
             TotalPayment             = this.TotalPayment,
         };
     }
 }