public async Task <IHttpActionResult> AddWish(ImagedWishDto wish) { var userId = long.Parse(User.Identity.GetUserId()); if (wish.Image != null) { wish.ImageUrl = _fileService.SaveBase64FileReturnUrl(FileType.Image, wish.Image.Type, wish.Image.Result); } var result = await _wishRepository.AddWish(userId, wish); // await _feedService.AddActivityFeed(userId); return(SuccessApiResult(new IdModel() { Id = result })); }
public async Task <IActionResult> addWish(WishForAddDto wish, string username) { var user = await _repo.GetUser(username); if (user.UserName.ToString() != User.FindFirst(ClaimTypes.NameIdentifier).Value) { return(Unauthorized()); } var wishToAdd = _mapper.Map <Wish>(wish); _wishRepo.AddWish(user, wishToAdd); if (await _repo.SaveAll()) { return(Ok(user)); } return(BadRequest("Problem with adding new wish!")); }