public ActionResult Create(PensionSystem pensionSystem) { if (ModelState.IsValid) { db.PensionSystems.Add(pensionSystem); var responseSave = DBHelper.SaveChanges(db); if (responseSave.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, responseSave.Message); } ViewBag.CompanyId = new SelectList(CombosHelper.GetCompanies(), "CompanyId", "Name", pensionSystem.CompanyId); return(View(pensionSystem)); }
public ActionResult Create() { var adminUser = WebConfigurationManager.AppSettings["AdminUser"]; if (adminUser == User.Identity.Name) { ViewBag.CompanyId = new SelectList(CombosHelper.GetCompanies(), "CompanyId", "Name"); var pensionSystemNew = new PensionSystem { Commission = 0, Bonus = 0, Input = 0, Total = 0, Top = 0, }; return(View(pensionSystemNew)); } //verifica el usuario logeado y envia su compania a la vista var user = db.Users.FirstOrDefault(u => u.UserName == User.Identity.Name); if (user == null) { return(RedirectToAction("Index", "Home")); } var pensionSystem = new PensionSystem { CompanyId = user.CompanyId, Commission = 0, Bonus = 0, Input = 0, Total = 0, Top = 0, }; return(View(pensionSystem)); }