public async Task Add(AdvertDTO advertDTO) { var UserId = Convert.ToInt32(_context.HttpContext.User.Claims.Where(x => x.Type == "UserId").First().Value); var advert = _mapper.Map <Advert>(advertDTO); advert.UserId = UserId; await _advertRepository.Add(advert); }
public Advert Add(Advert advert) { try { var ad = _advertRepository.Add(advert); return(ad); } catch (Exception e) { _logger.LogError("Exception at AdvertService.Add method", advert); throw new ApplicationException("An error occured when adding a new advert.", e); } }
public IActionResult Add(AddAdvertModels advert) { if (!ModelState.IsValid) { return(BadRequest()); } var userId = int.Parse(getUserIdHttpContext(HttpContext)); var user = userRepository.GetById(userId); advertRepository.Add(new Advert { Title = advert.Title, Description = advert.Description, OwnerUserId = userId, OwnerUser = user }); return(Ok()); }
public Task <string> Add(Advert advert) { return(_repo.Add(advert)); }
public async Task Add(AdvertDto advertDto) { await _iAdvertRepository.Add(AdvertMapper.MapDtoToAdvert(advertDto)); }