public ActionResult Create(NewBudgetView budget) { if (ModelState.IsValid) { var response = MovementsHelper.NewBudget(budget, User.Identity.Name); if (response.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, response.Message); } var adminUser = WebConfigurationManager.AppSettings["AdminUser"]; if (adminUser == User.Identity.Name) { ViewBag.CustomerId = new SelectList(CombosHelper.GetCustomers(), "CustomerId", "UserName", budget.CustomerId); ViewBag.ProjectId = new SelectList(CombosHelper.GetProjects(budget.CompanyId), "ProjectId", "Name", budget.ProjectId); ViewBag.CompanyId = new SelectList(CombosHelper.GetCompanies(), "CompanyId", "Name", budget.CompanyId); } else { var user = db.Users.FirstOrDefault(u => u.UserName == User.Identity.Name); ViewBag.CustomerId = new SelectList(CombosHelper.GetCustomers(user.CompanyId), "CustomerId", "UserName", budget.CustomerId); ViewBag.ProjectId = new SelectList(CombosHelper.GetProjects(user.CompanyId), "ProjectId", "Name", budget.ProjectId); } budget.DetailsSc01 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC01").ToList(); budget.DetailsSc02 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC02").ToList(); budget.DetailsSc03 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC03").ToList(); budget.DetailsSc04 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC04").ToList(); budget.DetailsSc05 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC05").ToList(); budget.DetailsSc06 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC06").ToList(); budget.DetailsSc07 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC07").ToList(); budget.DetailsSc08 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC08").ToList(); budget.DetailsSc09 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC09").ToList(); budget.DetailsSc10 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC10").ToList(); budget.DetailsSc11 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC11").ToList(); budget.DetailsSc12 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC12").ToList(); budget.DetailsSc13 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC13").ToList(); budget.DetailsSc14 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC14").ToList(); budget.DetailsSc15 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC15").ToList(); budget.DetailsSc16 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC16").ToList(); budget.DetailsSc17 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC17").ToList(); budget.DetailsSc18 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC18").ToList(); budget.DetailsSc19 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC19").ToList(); budget.DetailsSc20 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC20").ToList(); budget.DetailsSc21 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC21").ToList(); budget.DetailsSc22 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC22").ToList(); budget.DetailsSc23 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC23").ToList(); budget.DetailsSc24 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC24").ToList(); budget.DetailsSc25 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC25").ToList(); budget.DetailsSc26 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC26").ToList(); budget.DetailsSc27 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC27").ToList(); budget.DetailsSc28 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC28").ToList(); budget.DetailsSc29 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC29").ToList(); budget.DetailsSc30 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC30").ToList(); budget.DetailsSc31 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC31").ToList(); budget.DetailsSc32 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC32").ToList(); budget.DetailsSc33 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC33").ToList(); budget.DetailsSc34 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC34").ToList(); budget.DetailsSc35 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC35").ToList(); budget.DetailsSc36 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC36").ToList(); budget.DetailsSc37 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC37").ToList(); budget.DetailsSc38 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC38").ToList(); budget.DetailsSc39 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC39").ToList(); budget.DetailsSc40 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC40").ToList(); budget.DetailsSc41 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC41").ToList(); budget.DetailsSc42 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC42").ToList(); budget.DetailsSc43 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC43").ToList(); budget.DetailsSc44 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC44").ToList(); budget.DetailsSc45 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC45").ToList(); budget.DetailsSc46 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC46").ToList(); budget.DetailsSc47 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC47").ToList(); budget.DetailsSc48 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC48").ToList(); budget.DetailsSc49 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC49").ToList(); budget.DetailsSc50 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC50").ToList(); budget.DetailsSc51 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC51").ToList(); budget.DetailsSc52 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC52").ToList(); budget.DetailsSc53 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC53").ToList(); budget.DetailsSc54 = db.BudgetDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.SubcategoryCode == "SC54").ToList(); return(View(budget)); }