public IActionResult Save(ReasonCategoryMaster_VM reasonCategoryMaster_VM) { if (reasonCategoryMaster_VM != null) { reasonCategoryMaster_VM.ClientId = clientId; if (reasonCategoryMaster_VM.Id > 0) { if (_voucherReasonCategoryMasterRepository.Update(reasonCategoryMaster_VM, this.loginUserId) > 0) { TempData["Status"] = Helper.success_code; TempData["Message"] = Message.voucherCategoryUpdated; } else { TempData["Message"] = Message.voucherCategoryUpdatedError; } } else { if (_voucherReasonCategoryMasterRepository.Add(reasonCategoryMaster_VM, this.loginUserId) > 0) { TempData["Status"] = Helper.success_code; TempData["Message"] = Message.voucherCategoryAdded; } else { TempData["Message"] = Message.voucherCategoryAddedError; } } } return(RedirectToAction("List", "VoucherReasonCategory")); }
/// <summary> /// Function add category /// </summary> /// <param name="country_VM"></param> /// <param name="loginUserId"></param> /// <returns></returns> public int Add(ReasonCategoryMaster_VM reasonCategoryMaster_VM, int loginUserId) { var obj = new VoucherReasonCategoryMaster(); obj.Name = reasonCategoryMaster_VM.Name; obj.Status = reasonCategoryMaster_VM.Status; obj.ClientId = reasonCategoryMaster_VM.ClientId; obj.CreatedBy = loginUserId; obj.CreatedOn = DateTime.Now; _context.VoucherReasonCategoryMaster.Add(obj); return(_context.SaveChanges()); }
/// <summary> /// Function for update category /// </summary> /// <param name="country_VM"></param> /// <param name="loginUserId"></param> /// <returns></returns> public int Update(ReasonCategoryMaster_VM reasonCategoryMaster_VM, int loginUserId) { var obj = _context.VoucherReasonCategoryMaster.Where(x => x.Id == reasonCategoryMaster_VM.Id && x.IsDeleted == false).FirstOrDefault(); if (obj != null) { obj.Name = reasonCategoryMaster_VM.Name; obj.Status = reasonCategoryMaster_VM.Status; obj.ClientId = reasonCategoryMaster_VM.ClientId; obj.ModifiedBy = loginUserId; obj.ModifiedOn = DateTime.Now; return(_context.SaveChanges()); } return(0); }
public IActionResult Index(int Id = 0) { var category = new ReasonCategoryMaster_VM(); if (Id > 0) { category = _voucherReasonCategoryMasterRepository.Get(Id); if (category == null) { return(RedirectToAction("List", " VoucherReasonCategory")); } else { ViewData["Title"] = "Edit"; return(View(category)); } } else { ViewData["Title"] = "Add"; return(View(category)); } }