예제 #1
0
 public ActionResult CreateElectricBill(ElectrisityNumber eBill)
 {
     eBill.isPaid = false;
     db.ElectrisityNumbers.Add(eBill);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
예제 #2
0
        public string NewEBill(ElectrisityNumber elect)
        {
            if (elect.month.Year < 2000)
            {
                elect.month = DateTime.Now;
            }
            if (db.ElectrisityNumbers.Any())
            {
                var lastElBil = db.ElectrisityNumbers.OrderByDescending(s => s.month).FirstOrDefault();
                if (elect.tariff < 1)
                {
                    elect.tariff = lastElBil.tariff;
                }
                elect.summRub = (-lastElBil.conterNumber + elect.conterNumber) * elect.tariff;
            }
            else if (elect.tariff < 1)
            {
                elect.tariff  = 1;
                elect.summRub = 0;
            }

            db.ElectrisityNumbers.Add(elect);
            db.SaveChanges();
            var meetJson = new JavaScriptSerializer().Serialize(db.ElectrisityNumbers.OrderByDescending(s => s.month).ToList());

            return(wrap(meetJson));
        }
예제 #3
0
        private void InitDb()
        {
            WaterBill wBill = new WaterBill();

            wBill.coldWaterNum = 56;
            wBill.hotWaterNum  = 37;
            wBill.isPaid       = false;
            wBill.summRub      = 34;
            wBill.month        = DateTime.Now;
            if (db.WaterBills.ToList().Capacity == 0)
            {
                db.WaterBills.Add(wBill);
            }

            ElectrisityNumber eBill = new ElectrisityNumber();

            eBill.conterNumber = 986;
            eBill.isPaid       = false;
            eBill.summRub      = 354;
            eBill.month        = DateTime.Now;
            if (db.ElectrisityNumbers.ToList().Capacity == 0)
            {
                db.ElectrisityNumbers.Add(eBill);
            }

            RentBill rBill = new RentBill();

            rBill.isPaid = false;
            rBill.month  = DateTime.Now;
            if (db.RentBills.ToList().Capacity == 0)
            {
                db.RentBills.Add(rBill);
            }

            Meeting meeting = new Meeting();

            meeting.month = DateTime.Now;
            if (db.Meetings.ToList().Capacity == 0)
            {
                db.Meetings.Add(meeting);
            }

            Payment payment = new Payment();

            payment.month   = DateTime.Now;
            payment.summRub = 4;
            db.Payments.Add(payment);
            if (db.Payments.ToList().Capacity == 0)
            {
                db.SaveChanges();
            }
        }