public SummaryItemModel(ValidTaxModel validTax, InvalidTaxModel invalidTax) { ValidTax = validTax; InvalidTax = invalidTax; IsValid = invalidTax == null; Message = string.Empty; if (!IsValid) Message = invalidTax.AccountMessage + invalidTax.DescriptionMessage + invalidTax.CurrencyCodeMessage + invalidTax.AmountMessage; }
public SummaryItemModel Update(ValidTaxModel taxModel) { var tax = Mapper.Map<Tax>(taxModel); var validated = this.validator.ValidateItem(tax); if (validated is ValidTax) { this.taxCalculatorDal.Update(tax); return new SummaryItemModel(Mapper.Map<ValidTaxModel>(validated), null); } else return new SummaryItemModel(null, Mapper.Map<InvalidTaxModel>(validated)); }
public JsonResult Update() { int _id; var id = Request.QueryString["id"]; var account = Request.QueryString["account"]; var description = Request.QueryString["description"]; var currencyCode = Request.QueryString["currencyCode"]; var amount = Request.QueryString["amount"]; if (int.TryParse(id, out _id)) { var model = new ValidTaxModel(_id, account, description, currencyCode, amount); var taxCalculationBll = new TaxCalculationBll(); var summaryItem = taxCalculationBll.Update(model); if (summaryItem.IsValid) return Json(new { IsSuccess = true, message = "Successfully updated" }, JsonRequestBehavior.AllowGet); else return Json(new { isSuccess = false, message = summaryItem.Message }, JsonRequestBehavior.AllowGet); } return Json(new { isSuccess = false, message = "Unknown error" }, JsonRequestBehavior.AllowGet); }