public async Task <IHttpActionResult> PostSession(C.Session session) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var updatedSession = await _sessionHandler.AddSessionAsync(session.ToModel()); return(CreatedAtRoute("DefaultApi", new { id = session.Id }, updatedSession.ToContract())); }
public async Task <IHttpActionResult> PutSession(int id, C.Session session) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != session.Id) { return(BadRequest()); } var sessionExists = _sessionHandler.SessionExists(session.Id); if (!sessionExists) { return(NotFound()); } var updatedSession = await _sessionHandler.UpdateSessionAsync(id, session.ToModel()); return(StatusCode(HttpStatusCode.NoContent)); }
public static M.Session ToModel(this C.Session session) { return(Mapper.Map <C.Session, M.Session>(session)); }