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(); }
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(); }