示例#1
0
        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));
        }
示例#2
0
        // 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));
            }
        }