Exemplo n.º 1
0
 public IActionResult Create([Bind("GiftId,Title,Description,CreationDate,GenderId")] GiftViewModel giftViewModel)
 {
     if (!ModelState.IsValid)
     {
         _iGiftRepository.AddGift(giftViewModel);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(giftViewModel));
 }
Exemplo n.º 2
0
        public IActionResult CreateGift([FromForm] GiftViewModel gift)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var gifts = _iGiftRepository.AddGift(gift);

            return(View(gifts));
        }
        public async Task <IHttpActionResult> AddGift(GiftDto gift)
        {
            var userId = long.Parse(User.Identity.GetUserId());
            var id     = await _giftRepository.AddGift(userId, gift);

            return(SuccessApiResult(new IdModel()
            {
                Id = id
            }));
        }