public GeneratedBill Insert(GeneratedBill item)
        {
            var inserted = GeneratedBills.Add(item);

            _ctx.SaveChanges();

            return(inserted);
        }
        public void Update(GeneratedBill item)
        {
            var updated = GeneratedBills.FirstOrDefault(x => x.UniqueId == item.UniqueId);

            updated.Date = item.Date;
            updated.CSV  = item.CSV;

            _ctx.SaveChanges();
        }
 public static BillGeneratorViewModel ToViewModel(this GeneratedBill item)
 {
     return(new BillGeneratorViewModel
     {
         Id = item.UniqueId,
         MansionId = item.MansionId,
         MansionName = item.Mansion.Address,
         CSV = item.CSV,
         Date = item.Date.ToString("MMMM-yyyy")
     });
 }
Example #4
0
        public HttpResponseMessage Post([FromBody] GeneratedBill value)
        {
            try
            {
                lock (thisLock)
                {
                    using (var context = new NestinDBEntities())
                    {
                        var lastBill = context.viewLatestFlatBills.Where(gb => gb.FlatID == value.FlatID && gb.SocietyID == value.SocietyID &&
                                                                         gb.SocietyBillID == value.SocietyBillID).First();

                        value.PreviousMonthBalance = lastBill.CurrentMonthBalance;

                        context.GeneratedBills.Add(value);
                        context.SaveChanges();

                        var user = context.ViewSocietyUsers.Where(u => u.ResID == value.ResID).First();

                        Log.log(" Payment Data Updated : " + DateTime.Now.ToString());

                        Message message = new Message();
                        message.Topic       = "Bill";
                        message.SocietyID   = value.SocietyID;
                        message.TextMessage = "Your bill has been credited with Rs." + value.AmountPaid.ToString();

                        Notifications notifications = new Notifications(context);
                        notifications.Notify(Notifications.TO.Flat, value.FlatID, message);

                        /*
                         *  BillingNotification bill = new BillingNotification(context, user.MobileNo);
                         *  bill.NotifyResidents(message, "Bill");*/

                        String resp     = "{\"Response\":\"OK\"}";
                        var    response = Request.CreateResponse(HttpStatusCode.OK);
                        response.Content = new StringContent(resp, System.Text.Encoding.UTF8, "application/json");
                        return(response);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.log(" Payment Data Updated error : " + ex.Message);
                String resp     = "{\"Response\":\"FAIL\",\"Error\":\"" + ex.Message + "\"}";
                var    response = Request.CreateResponse(HttpStatusCode.BadRequest);
                response.Content = new StringContent(resp, System.Text.Encoding.UTF8, "application/json");
                return(response);
            }
        }
 public GeneratedBill Insert(GeneratedBill item)
 {
     return(_generatedBillRepository.Insert(item));
 }
 public void Update(GeneratedBill item)
 {
     _generatedBillRepository.Update(item);
 }