public IHttpActionResult PostSession(Session session) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _sessionsRepository.Create(session); return(CreatedAtRoute("DefaultApi", new { id = session.Id }, session)); }
public Task <HttpResponseMessage> Create([FromBody] Session session) { if (userRepository.Get(session.User.Id) != null && userRepository.Get(session.User.Id).Password == session.User.Password && userRepository.Get(session.User.Id).Username == session.User.Username) { sessionRepository.Create(session); return(Task.FromResult(Request.CreateResponse(HttpStatusCode.Created))); } return(Task.FromResult(Request.CreateResponse(HttpStatusCode.NotFound))); }