示例#1
0
        public string Save(string id, string word, string translation, User owner)
        {
            if (string.IsNullOrEmpty(word) || string.IsNullOrEmpty(translation) || owner == null)
            {
                throw new ArgumentException("Word, translation or user is null");
            }

            if (string.IsNullOrEmpty(id))
            {
                return Create(word, translation, owner);
            }
            else
            {
                var card = GetCardByID(id);
                if (card != null && card.Owner.Id == owner.Id)
                {
                    return Update(card, word, translation);
                }
                else
                {
                    return Create(word, translation, owner);
                }
            }
        }
示例#2
0
 private string Create(string word, string translation, User owner)
 {
     var card = new Card {Word = word, Translation = translation, Owner = owner};
     card = Algorithm.InitCard(card);
     card = cardRepo.Add(card);
     return card.Id;
 }