コード例 #1
0
 public void GivenASessionNamed(string p0)
 {
     sessionTemp = new Session {
         Id = 1, Title = p0, Price = 35
     };
     saveSessionTemp = new SaveSessionResource {
         Title = p0, Price = 35
     };
 }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }