public static Response EditBudget(EditBudgetView budget) { using (var transacction = db.Database.BeginTransaction()) { try { var budgetEdit = db.Budgets.FirstOrDefault(odt => odt.BudgetId == budget.BudgetId); if (budgetEdit != null) { budgetEdit.Remarks = budget.Remarks; db.Entry(budgetEdit).State = EntityState.Modified; } db.SaveChanges(); transacction.Commit(); return(new Response { Succeeded = true }); } catch (Exception ex) { transacction.Rollback(); return(new Response { Message = ex.Message, Succeeded = false }); } } }
private void EditBudget() { var vm = new EditBudgetViewModel(new UnitOfWorkFactory(), Budget); vm.Init(); var window = new EditBudgetView(vm); if (window.ShowDialog() ?? false) { OnPropertyChanged(nameof(Budget)); } }
public ActionResult Edit(EditBudgetView budget) { if (ModelState.IsValid) { var response = MovementsHelper.EditBudget(budget); if (response.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, response.Message); } return(View(budget)); }
private void NewBudget() { var budget = new Budget(); var vm = new EditBudgetViewModel(new UnitOfWorkFactory(), budget); vm.Init(); var window = new EditBudgetView(vm); if (window.ShowDialog() ?? false) { BudgetList.Add(budget); Budget = budget; } }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var budget = db.Budgets.Find(id); if (budget == null) { return(HttpNotFound()); } var editView = new EditBudgetView { BudgetId = budget.BudgetId, Company = budget.Company.Name, Customer = budget.Customer.FullName, Project = budget.Project.Name, Date = budget.Date, Remarks = budget.Remarks, DetailsSc01 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC01").ToList(), DetailsSc02 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC02").ToList(), DetailsSc03 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC03").ToList(), DetailsSc04 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC04").ToList(), DetailsSc05 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC05").ToList(), DetailsSc06 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC06").ToList(), DetailsSc07 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC07").ToList(), DetailsSc08 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC08").ToList(), DetailsSc09 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC09").ToList(), DetailsSc10 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC10").ToList(), DetailsSc11 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC11").ToList(), DetailsSc12 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC12").ToList(), DetailsSc13 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC13").ToList(), DetailsSc14 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC14").ToList(), DetailsSc15 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC15").ToList(), DetailsSc16 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC16").ToList(), DetailsSc17 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC17").ToList(), DetailsSc18 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC18").ToList(), DetailsSc19 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC19").ToList(), DetailsSc20 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC20").ToList(), DetailsSc21 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC21").ToList(), DetailsSc22 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC22").ToList(), DetailsSc23 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC23").ToList(), DetailsSc24 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC24").ToList(), DetailsSc25 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC25").ToList(), DetailsSc26 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC26").ToList(), DetailsSc27 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC27").ToList(), DetailsSc28 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC28").ToList(), DetailsSc29 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC29").ToList(), DetailsSc30 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC30").ToList(), DetailsSc31 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC31").ToList(), DetailsSc32 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC32").ToList(), DetailsSc33 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC33").ToList(), DetailsSc34 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC34").ToList(), DetailsSc35 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC35").ToList(), DetailsSc36 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC36").ToList(), DetailsSc37 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC37").ToList(), DetailsSc38 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC38").ToList(), DetailsSc39 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC39").ToList(), DetailsSc40 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC40").ToList(), DetailsSc41 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC41").ToList(), DetailsSc42 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC42").ToList(), DetailsSc43 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC43").ToList(), DetailsSc44 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC44").ToList(), DetailsSc45 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC45").ToList(), DetailsSc46 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC46").ToList(), DetailsSc47 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC47").ToList(), DetailsSc48 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC48").ToList(), DetailsSc49 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC49").ToList(), DetailsSc50 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC50").ToList(), DetailsSc51 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC51").ToList(), DetailsSc52 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC52").ToList(), DetailsSc53 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC53").ToList(), DetailsSc54 = db.BudgetDetails.Where(odt => odt.BudgetId == budget.BudgetId && odt.SubcategoryCode == "SC54").ToList(), }; return(View(editView)); }