public void GivenASessionNamed(string p0) { sessionTemp = new Session { Id = 1, Title = p0, Price = 35 }; saveSessionTemp = new SaveSessionResource { Title = p0, Price = 35 }; }
public async Task <IActionResult> PutAsync(int userId, [FromBody] SaveSessionResource resource) { var session = _mapper.Map <SaveSessionResource, Session>(resource); var result = await _sessionService.UpdateAsync(userId, session); if (!result.Success) { return(BadRequest(result.Message)); } var sessionResource = _mapper.Map <Session, SessionResource>(result.Resource); return(Ok(sessionResource)); }
public async Task <IActionResult> PostAsync([FromBody] SaveSessionResource resource) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetMessages())); } var session = _mapper.Map <SaveSessionResource, Session>(resource); var result = await _sessionService.SaveAsync(session); if (!result.Success) { return(BadRequest(result.Message)); } var userResource = _mapper.Map <Session, SessionResource>(result.Resource); return(Ok(userResource)); }
public async Task <IActionResult> PutAsync(int tutorId, int sessionId, [FromBody] SaveSessionResource resource) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var session = _mapper.Map <SaveSessionResource, Session>(resource); var result = await _sessionService.UpdateAsync(tutorId, sessionId, session); if (!result.Success) { return(BadRequest(result.Message)); } var SessionResource = _mapper.Map <Session, SessionResource>(result.Resource); return(Ok(SessionResource)); }