public async Task <IActionResult> Create([Bind("ID,Name,Layout")] Room room) { if (ModelState.IsValid) { await _room.AddNewRoom(room); return(RedirectToAction(nameof(Index))); } return(View(room)); }
// POST api/<controller> public HttpResponseMessage Post([FromBody] Room room) { var useremail = new TApiAuth().GetLoggedInUsername(Request); if (string.IsNullOrEmpty(useremail)) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } var user = _userManager.GetUserFromMailId(useremail); if (user.isAdmin.HasValue && user.isAdmin.Value) { room.Id = Guid.NewGuid().ToString(); _roomManager.AddNewRoom(room); return(new HttpResponseMessage(HttpStatusCode.Created)); } else { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } }