public ActionResult MakePayment(int id = 0) { List <TempOrderViewModel> temporder = TempData["mytemp"] as List <TempOrderViewModel>; if (temporder != null) { ViewBag.Orders = temporder; decimal totalamount = 0M; foreach (var item in ViewBag.Orders) { totalamount += Convert.ToDecimal(item.Total); } tblSetting tbs = _db.tblSettings.OrderByDescending(a => a.SettingId).Take(1).FirstOrDefault(); decimal discountrate = Convert.ToDecimal(tbs.DiscountRate); ViewBag.TotalAmount = totalamount; decimal discountamount = discountrate / 100 * totalamount; ViewBag.DiscountAmount = discountamount; ViewBag.NetAmount = totalamount - discountamount; } else { if (ViewBag.Orders != null) { decimal totalamount = 0M; foreach (var item in ViewBag.Orders) { totalamount += Convert.ToDecimal(item.Total); } } } return(View()); }
public bool UpdateSetting(SettingVM settingVM) { using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction()) { try { tblSetting setting = unitOfWork.TblSettingRepository.GetByID(settingVM.SettingID); setting.DesignationID = settingVM.DesignationID; setting.SettingCode = settingVM.SettingCode; setting.SettingDesc = settingVM.SettingDescription; setting.ModifiedDate = DateTime.Now; setting.ModifiedBy = settingVM.ModifiedBy; unitOfWork.TblSettingRepository.Update(setting); unitOfWork.Save(); //Complete the Transaction dbTransaction.Commit(); return(true); } catch (Exception ex) { //Roll back the Transaction dbTransaction.Rollback(); return(false); } } }
public ActionResult AddOrEdit(SettingViewModel sm) { using (ELaundryDBEntities db = new ELaundryDBEntities()) { if (sm.SettingId == 0) { tblSetting tb = new tblSetting(); tb.DiscountRate = sm.DiscountRate; tb.Description = sm.Description; tb.IsActive = sm.IsActive; db.tblSettings.Add(tb); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { tblSetting tbm = db.tblSettings.Where(m => m.SettingId == sm.SettingId).FirstOrDefault(); tbm.DiscountRate = sm.DiscountRate; tbm.Description = sm.Description; tbm.IsActive = sm.IsActive; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult Delete(int id) { using (ELaundryDBEntities db = new ELaundryDBEntities()) { tblSetting sm = db.tblSettings.Where(x => x.SettingId == id).FirstOrDefault(); db.tblSettings.Remove(sm); db.SaveChanges(); return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } }
public HttpResponseMessage PutSettings(SettingsModel Obj) { int userId = User.Identity.getId(); tblSetting x = _db.tblSettings.Where(m => m.tbUserID == userId).FirstOrDefault(); x.isAlertEnabled = Obj.isAlertEnabled; x.isAllSettingsEnabled = Obj.isAllSettingsEnabled; x.isPushNotificationEnabled = Obj.isPushNotificationEnabled; _db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "The changes are updated to the database")); }
public Settings GetSettings() { int userID = User.Identity.UserID(); Settings set = new Settings(); tblSetting setting = _db.tblSetting.First(x => x.tblUserId == userID); set.isAlertsEnabled = setting.IsAlertsEnabled; set.isallSettingsEnabled = setting.IsAllSettingsEnabled; set.isPushNotificationsEnabled = setting.IsPushNotificationsEnabled; return(set); }
public Settings GetSettings(long userID) { using (SandeepDBEntities db = new SandeepDBEntities()) { Settings set = new Settings(); tblSetting setting = db.tblSetting.First(x => x.tblUserID == userID); set.isAlertsEnabled = setting.IsAlertsEnabled; set.isallSettingsEnabled = setting.IsAllSettingsEnabled; set.isPushNotificationsEnabled = setting.IsPushNotificationsEnabled; return(set); } }
public void AddSetting(int userid, string section, string key, string value, bool IsFixed = false) { tblSetting setting = new tblSetting(); setting.UserId = userid; setting.SectionName = section; setting.Key = key; setting.Value = value; setting.IsFixedInGrid = IsFixed; db.tblSettings.Add(setting); db.SaveChanges(); }
public void UpdateSetting(int userid, string section, string key, string value) { tblSetting setting = (from u in db.tblSettings where u.UserId == userid && u.SectionName == section && u.Key == key select u).FirstOrDefault(); if (setting != null) { setting.Value = value; db.SaveChanges(); } else { AddSetting(userid, section, key, value, false); } }
public bool DeleteSetting(int settingID) { using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction()) { try { tblSetting setting = unitOfWork.TblSettingRepository.GetByID(settingID); unitOfWork.TblSettingRepository.Delete(setting); unitOfWork.Save(); //Complete the Transaction dbTransaction.Commit(); return(true); } catch (Exception ex) { //Roll back the Transaction dbTransaction.Rollback(); return(false); } } }
public JsonResult InsertInvoice(tblInvoice tb) { tblInvoice tbl = _db.tblInvoices.OrderByDescending(ti => ti.InvoiceId).Take(1).FirstOrDefault(); tblSetting tbs = _db.tblSettings.OrderByDescending(s => s.SettingId).Take(1).FirstOrDefault(); tblInvoice t = new tblInvoice(); if (tbl != null) { t.InvoiceId = tbl.InvoiceId; } else { t.InvoiceId = 1; } t.OrderId = tb.OrderId; decimal taxamount = Convert.ToDecimal(tb.GrossAmount * 15 / 100); decimal grossamount = Convert.ToDecimal(tb.GrossAmount + taxamount); decimal discountamount = Convert.ToDecimal(tbs.DiscountRate / 100 * grossamount); t.DiscountAmount = discountamount; t.TaxAmount = taxamount; t.GrossAmount = tb.GrossAmount; t.NetAmount = tb.GrossAmount + taxamount - discountamount; t.InvoiceDate = DateTime.Today; t.UserId = Convert.ToInt32(Session["userid"]); t.BranchId = Convert.ToInt32(Session["branchid"]); _db.tblInvoices.Add(t); _db.SaveChanges(); return(Json(1, JsonRequestBehavior.AllowGet)); }
public void AddTotblSettings(tblSetting tblSetting) { AddObject("tblSettings", tblSetting); }
public static tblSetting CreatetblSetting(string version, global::System.DateTime lastSync, bool isStartingSync) { tblSetting tblSetting = new tblSetting(); tblSetting.Version = version; tblSetting.LastSync = lastSync; tblSetting.IsStartingSync = isStartingSync; return tblSetting; }