public async Task <PubDto> RegisterPubAsync(PubDtoForCreation dto) { if (dto == null) { throw new RestExceptions(HttpStatusCode.BadRequest, new { Pub = "Pub cannot be null" }); } dto.DateAdded = DateTime.Now; dto.ImagePath = "assets/images/pubs/noimage.jpg"; if (await _authRepository.UserExists(dto.Username.ToLower())) { throw new RestExceptions(HttpStatusCode.BadRequest, new { Pub = "Invalid Pub" }); } var pubToSave = _mapper.Map <PubDtoForCreation, Pub>(dto); var toReturn = await _authRepository.RegisterPubAsync(pubToSave, dto.Password); var result = _mapper.Map <Pub, PubDto>(toReturn); return(result); }
public async Task <IActionResult> RegisterPub(PubDtoForCreation dto) { await _services.RegisterPubAsync(dto); return(StatusCode(201)); }