public async Task <IActionResult> Create(RoomsCreateModel model) { if (!IsUserAuthenticated()) { return(Redirect("/Users/Login")); } if (!IsAdminAndActive()) { return(Redirect("/Rooms/List")); } if (ModelState.IsValid) { Room room = new Room { Number = model.Number, Capacity = model.Capacity, Price = model.Price, Description = model.Description, Type = model.Type, IsFree = model.IsFree }; _context.Add(room); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(List))); } return(View(model)); }
// GET: Rooms/Create public IActionResult Create() { if (!IsUserAuthenticated()) { return(Redirect("/Users/Login")); } if (!IsAdminAndActive()) { return(Redirect("/Rooms/List")); } RoomsCreateModel model = new RoomsCreateModel(); return(View(model)); }