public async Task <SessionDTO> PutAsync(SessionCreateDTO session) { this.Logger.LogTrace($"{nameof(this.PutAsync)} called"); var result = await this.SessionService.CreateAsync(this.Mapper.Map <SessionUpdateModel>(session)); return(this.Mapper.Map <SessionDTO>(result)); }
public IActionResult Create(SessionCreateDTO sessionDto) { var user = _userRepository.GetByEmail(sessionDto.email); if (user == null) { throw new NotFoundError("User not found!"); } if (!user.Authenticate(sessionDto.password)) { throw new ValidationError("Incorrect Password!"); } var token = _userJwtService.Call(user); return(new ContentResult() { Content = JsonSerializer.Serialize(new { token = token, email = user.Email }), StatusCode = 201, ContentType = "application/json" }); }