public ActionResult Edit() { int id = ((EInvoiceContext)FXContext.Current).CurrentCompany.id; ITaxAuthorityService _taxSvc = IoC.Resolve <ITaxAuthorityService>(); IList <TaxAuthority> tax = _taxSvc.GetAll(); ViewData["tax"] = tax; ICompanyService _comSrv = IoC.Resolve <ICompanyService>(); Company model = _comSrv.Getbykey(id); return(View(model)); }
public ActionResult Update(int id) { Company _currentCompany = ((EInvoiceContext)FXContext.Current).CurrentCompany; if (id != _currentCompany.id) { return(Redirect("/Home/PotentiallyError")); } ICompanyService _comSrv = IoC.Resolve <ICompanyService>(); Company model = _comSrv.Getbykey(_currentCompany.id); try { TryUpdateModel <Company>(model); model.TaxCode = Utils.formatTaxcode(model.TaxCode); _comSrv.Save(model); _comSrv.CommitChanges(); Messages.AddFlashMessage(Resources.Message.Com_UMesInfSuccess); log.Info("Update Company: " + HttpContext.User.Identity.Name); return(RedirectToAction("DetailCurrent")); } catch (HttpRequestValidationException ex) { return(Redirect("/Home/PotentiallyError")); } catch (ArgumentException ex) { return(Redirect("/Home/PotentiallyError")); } catch (Exception ex) { Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại!"); log.Error("Error Update-" + ex); ITaxAuthorityService _taxSvc = IoC.Resolve <ITaxAuthorityService>(); IList <TaxAuthority> tax = _taxSvc.GetAll(); ViewData["tax"] = tax; return(View("Edit", model)); } }