Пример #1
0
        public void UpdateCard(int?id, CardDTO cardDto)
        {
            if (id == null)
            {
                throw new ValidationException("Nonexistent ID", HttpStatusCode.BadRequest, "");
            }
            var card = cardDto.ToModel();

            card.Id = id.Value;
            Database.CardSet.Update(card);
            Database.Save();
        }
Пример #2
0
        public void CreateCard(CardDTO cardDto)
        {
            Card card = cardDto.ToModel();

            if (cardDto.CardGroupId != null)
            {
                var cardGroup = Database.GroupSet.Get((cardDto.CardGroupId.Value));
                if (cardGroup != null)
                {
                    card.GroupSet.Add(cardGroup);
                }
            }

            Database.CardSet.Create(card);
            Database.Save();
        }