public ActionResult UpdateUser(PaymentDetail _paymentDetail) { try { int VarpaymentID = _paymentRepository.UpdatePaymentDetail(_mapper.Map <Demo.Core.Data.Model.PaymentDetail>(_paymentDetail)); return(VarpaymentID == 0 ? NotFound(VarpaymentID) : (ActionResult)Ok(200)); } catch (Exception ex) { throw ex; } }
public ActionResult Edit(PaymentViewModel model) { if (ModelState.IsValid) { if (Request["Submit"] == "Save") { var Payment = paymentRepository.GetPaymentById(model.Id); AutoMapper.Mapper.Map(model, Payment); Payment.ModifiedUserId = WebSecurity.CurrentUserId; Payment.ModifiedDate = DateTime.Now; var check = Request["group_choice"]; Payment.TargetName = check; Erp.Domain.Repositories.CategoryRepository categoryRepository = new Erp.Domain.Repositories.CategoryRepository(new Domain.ErpDbContext()); var item = categoryRepository.GetCategoryByName(Payment.Name).Value; Payment.ShortName = item.ToString(); paymentRepository.UpdatePayment(Payment); var paymentDetail = paymentDetailRepository.GetPaymentDetailByPaymentId(model.Id); paymentDetail.ModifiedUserId = WebSecurity.CurrentUserId; paymentDetail.ModifiedDate = DateTime.Now; paymentDetail.Name = model.Name; paymentDetail.Amount = model.Amount; paymentDetailRepository.UpdatePaymentDetail(paymentDetail); TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess; return(RedirectToAction("Index")); } return(View(model)); } return(View(model)); //if (Request.UrlReferrer != null) // return Redirect(Request.UrlReferrer.AbsoluteUri); //return RedirectToAction("Index"); }
public async Task <IActionResult> UpdatePost([FromBody] PaymentDetail model) { if (ModelState.IsValid) { try { await _paymentRepository.UpdatePaymentDetail(model); return(Ok(true)); } catch (Exception ex) { if (ex.GetType().FullName == "Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException") { return(NotFound()); } return(BadRequest()); } } return(BadRequest()); }