public JsonResult SaveEvent(BillPayment e) { var status = false; using (BillCalendarDatabaseEntities dc = new BillCalendarDatabaseEntities()) { if (e.PaymentId > 0) { // Update the event var v = dc.BillPayments.Where(a => a.PaymentId == e.PaymentId).FirstOrDefault(); if (v != null) { v.PayeeName = e.PayeeName; v.PaymentAmount = e.PaymentAmount; v.DueDate = e.DueDate; v.PaidDate = e.PaidDate; v.Description = e.Description; v.Paid = e.Paid; v.ThemeColor = e.ThemeColor; v.username = e.username; } } else { dc.BillPayments.Add(e); } dc.SaveChanges(); status = true; } return(new JsonResult { Data = new { status = status } }); }
public JsonResult DeleteEvent(int paymentID) { var status = false; using (BillCalendarDatabaseEntities dc = new BillCalendarDatabaseEntities()) { var v = dc.BillPayments.Where(a => a.PaymentId == paymentID).FirstOrDefault(); if (v != null) { dc.BillPayments.Remove(v); dc.SaveChanges(); status = true; } } return(new JsonResult { Data = new { status = status } }); }