public ActionResult Edit(int id, FinancialEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.FinId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateFinancialService(); if (service.UpdateFinancial(model)) { TempData["SaveResult"] = "The information was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "The information could not be updated."); return(View(model)); }
public bool UpdateFinancial(FinancialEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Financials .Single(e => e.FinId == model.FinId); entity.FinId = model.FinId; entity.Address = model.Address; entity.ListPrice = model.ListPrice; entity.PurchasePrice = model.PurchasePrice; entity.LendersName = model.LendersName; entity.TypeOfMortgages = model.TypeOfMortgages; entity.InterestRate = model.InterestRate; entity.DownPayment = model.DownPayment; entity.MonthlyPayments = model.MonthlyPayments; entity.RemainingYearsOnLoan = (string)model.RemainingYearsOnLoan; entity.TaxAssessment = model.TaxAssessment; entity.AnnualTaxAmount = model.AnnualTaxAmount; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id) { var service = CreateFinancialService(); var detail = service.GetFinancialById(id); var model = new FinancialEdit { FinancialId = detail.FinancialId, CategoryType = detail.CategoryType, Title = detail.Title, ResourceType = detail.ResourceType, Description = detail.Description, City = detail.City, State = detail.State, InPerson = detail.InPerson, Url = detail.Url, }; return(View(model)); }
public bool UpdateFinancial(FinancialEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Financials .Single(e => e.FinancialId == model.FinancialId && e.OwnerId == _userId); entity.CategoryType = model.CategoryType; entity.Title = model.Title; entity.ResourceType = model.ResourceType; entity.Description = model.Description; entity.City = model.City; entity.State = model.State; entity.InPerson = model.InPerson; entity.Url = model.Url; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id) { var service = CreateFinancialService(); var detail = service.GetFinancialById(id); var model = new FinancialEdit { FinId = detail.FinId, Address = detail.Address, ListPrice = detail.ListPrice, PurchasePrice = detail.PurchasePrice, LendersName = detail.LendersName, TypeOfMortgages = detail.TypeOfMortgages, InterestRate = detail.InterestRate, DownPayment = detail.DownPayment, MonthlyPayments = detail.MonthlyPayments, RemainingYearsOnLoan = detail.RemainingYearsOnLoan, TaxAssessment = detail.TaxAssessment, AnnualTaxAmount = detail.AnnualTaxAmount }; return(View(model)); }