public ActionResult Create() { var user = User.Identity.GetUserId(); if (User.IsInRole("Admin")) { ViewBag.FillStationList = ListFillStationsByUserId.createAllListItems(db); } else { ViewBag.FillStationList = ListFillStationsByUserId.createListItems(db, user); } ViewBag.TimeBreakList = ListTimeBreakFill.createListItems(db); return(View()); }
public ActionResult Create(FillStationTimeBreak fillStationTimeBreak) { if (ModelState.IsValid) { if (ValidateFillStationTimeBreak.AlreadyExistsFillStationTimeBreak(fillStationTimeBreak)) { ModelState.AddModelError(string.Empty, "O posto já contém este intervalo."); var userId = User.Identity.GetUserId(); if (User.IsInRole("Admin")) { ViewBag.FillStationList = ListFillStationsByUserId.createAllListItems(db); } else { ViewBag.FillStationList = ListFillStationsByUserId.createListItems(db, userId); } ViewBag.TimeBreakList = ListTimeBreakFill.createListItems(db); return(View(fillStationTimeBreak)); } db.FillStationTimeBreaks.Add(fillStationTimeBreak); db.SaveChanges(); return(RedirectToAction("Index")); } var user = User.Identity.GetUserId(); if (User.IsInRole("Admin")) { ViewBag.FillStationList = ListFillStationsByUserId.createAllListItems(db); } else { ViewBag.FillStationList = ListFillStationsByUserId.createListItems(db, user); } ViewBag.TimeBreakList = ListTimeBreakFill.createListItems(db); return(View(fillStationTimeBreak)); }