public Room(MNewRoom newRoom, int personId) { Id = 0; Name = newRoom.Name; Code = newRoom.Code; ExpirationDate = newRoom.ExpirationDate; Description = newRoom.Description; CurrentState = (int)ERoomState.Building; NumberOfStudents = 0; PersonId = personId; }
public IActionResult CreateRoom([FromBody] MNewRoom newRoom) { var errors = new List <MModelError>(); newRoom.ValidRoom(_uRoom, ref errors); if (errors.Any()) { return(BadRequest(ResponseContent.Create(errors, HttpStatusCode.BadRequest, "Campo(s) inválido(s)!"))); } if (newRoom.ExpirationDate != null && newRoom.ExpirationDate < DateTime.Now) { return(BadRequest(ResponseContent.Create(errors, HttpStatusCode.BadRequest, $"A data do fim da sala deve ser maior que hoje, {DateTime.Now:dd/MM/yyyy}!"))); } var authenticatedUserId = HttpContext.Session.GetSessionPersonId(); _bRoom.Save(newRoom, authenticatedUserId); _bHistory.SaveHistory(authenticatedUserId, "Usuário criou uma nova sala"); return(Ok(ResponseContent.Create(null, HttpStatusCode.Created, "Sala criada com sucesso!"))); }