Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> RegisterPub(PubDtoForCreation dto)
        {
            await _services.RegisterPubAsync(dto);

            return(StatusCode(201));
        }