Exemple #1
0
        public IHttpActionResult CreateGroupCards(GroupCardsDTO groupCardDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var groupCard = Mapper.Map <GroupCardsDTO, GroupCards>(groupCardDTO);

            _context.GroupCards.Add(groupCard);
            _context.SaveChanges();

            groupCardDTO.Id = groupCard.Id;

            return(Created(new Uri(Request.RequestUri + "/" + groupCard.Id), groupCardDTO));
        }
Exemple #2
0
        public IHttpActionResult UpdateGroupCard(int id, GroupCardsDTO groupCardDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var groupCardInDB = _context.GroupCards.SingleOrDefault(c => c.Id == id);

            if (groupCardInDB == null)
            {
                return(NotFound());
            }

            Mapper.Map(groupCardDTO, groupCardInDB);

            _context.SaveChanges();

            return(Ok());
        }