Beispiel #1
0
        public int AddAward(AwardDTO award)
        {
            if (award == null || string.IsNullOrWhiteSpace(award.Title) || award.Title.Length > ModelRules.MaxNameLength)
            {
                return(ModelRules.LowerBoundOfId - 1);
            }

            if (string.IsNullOrWhiteSpace(award.Description))
            {
                award.Description = string.Empty;
            }

            award.Id = ModelRules.LowerBoundOfId - 1;

            return(dal.AddAward(award));
        }
 public Guid?AddAward(Award award)
 {
     if (award == null)
     {
         throw new ArgumentNullException(nameof(Award));
     }
     if (_awardsDal.GetAwards().Count() > 0)
     {
         foreach (var item in _awardsDal.GetAwards())
         {
             if (item.Title == award.Title)
             {
                 Console.WriteLine("An award with the same title already exists");
                 return(null);
             }
         }
     }
     award.ID = Guid.NewGuid();
     _awardsDal.AddAward(award);
     return(award.ID);
 }