/// <summary> /// Creates a banner add. /// </summary> /// <param name="add">The banner add.</param> /// <returns></returns> /// <exception cref="System.ArgumentException">Banner add is invalid.</exception> public int CreateBannerAdd(BannerAdd add) { //Validate banner add. if(add == null) { throw new ArgumentException("Banner add is invalid."); } //Add and save to the database. _context.BannerAdds.Add(add); _context.SaveChanges(); //Return the new id. return add.Id; }
/// <summary> /// Updates a banner add. /// </summary> /// <param name="add">The banner add.</param> public void UpdateBannerAdd(BannerAdd add) { BannerAdd addToUpdate = (from a in _context.BannerAdds where a.Id.Equals(add.Id) select a).FirstOrDefault(); if (!string.IsNullOrEmpty(add.FileName)) { addToUpdate.FileName = add.FileName; } addToUpdate.Name = add.Name; addToUpdate.RotationEnd = add.RotationEnd; addToUpdate.RotationStart = add.RotationStart; _context.SaveChanges(); }