public IActionResult Save(Currency_VM currency_VM) { if (currency_VM != null) { currency_VM.ClientId = clientId; if (currency_VM.Id > 0) { if (_currencyRepository.Update(currency_VM, this.loginUserId) > 0) { TempData["Status"] = Helper.success_code; TempData["Message"] = Message.currencyUpdated; } else { TempData["Message"] = Message.currencyUpdateError; } } else { if (_currencyRepository.Add(currency_VM, this.loginUserId) > 0) { TempData["Status"] = Helper.success_code; TempData["Message"] = Message.currencyAdded; } else { TempData["Message"] = Message.currencyAddedError; } } } return(RedirectToAction("List", "Currency")); }
/// <summary> /// Function for add currency /// </summary> /// <param name="currency_VM"></param> /// <param name="loginUserId"></param> /// <returns></returns> public int Add(Currency_VM currency_VM, int loginUserId) { var obj = new Emenu_Currency(); obj.Currency = currency_VM.Currency; obj.Symbol = currency_VM.Symbol; obj.SymbolAR = currency_VM.SymbolAR; obj.CreatedOn = DateTime.Now; obj.CreatedBy = loginUserId; obj.ClientId = currency_VM.ClientId; _context.Emenu_Currency.Add(obj); return(_context.SaveChanges()); }
/// <summary> /// Function for Update currency /// </summary> /// <param name="currency_VM"></param> /// <param name="loginUserId"></param> /// <returns></returns> public int Update(Currency_VM currency_VM, int loginUserId) { var currency = _context.Emenu_Currency.Where(x => x.Id == currency_VM.Id && x.IsDeleted == false).FirstOrDefault(); if (currency != null) { currency.Currency = currency_VM.Currency; currency.Symbol = currency_VM.Symbol; currency.SymbolAR = currency_VM.SymbolAR; currency.ModifiedBy = loginUserId; currency.ModifiedOn = DateTime.Now; currency.ClientId = currency_VM.ClientId; return(_context.SaveChanges()); } return(0); }
public IActionResult Index(int Id = 0) { var currency = new Currency_VM(); if (Id > 0) { currency = _currencyRepository.Get(Id, loginUserId); if (currency == null) { return(RedirectToAction("List", "Currency")); } else { ViewData["Title"] = "Edit"; return(View(currency)); } } else { ViewData["Title"] = "Add"; return(View(currency)); } }