public EditClipModel() { clip = new Clip(); AllCategories = new List<SelectListItem>(); VideoCategories = new List<SelectListItem>(); FotoCategories = new List<SelectListItem>(); }
public void SaveClip(Clip clip) { if (clip.Id == 0) { contex.Clip.Add(clip); } else { Clip dbEntry = contex.Clip.Find(clip.Id); if (dbEntry != null) { dbEntry.Title = clip.Title; dbEntry.Description = clip.Description; dbEntry.Categories = dbEntry.Categories.Union(clip.Categories).ToList(); dbEntry.ImageData = clip.ImageData; dbEntry.ImageMimeType = clip.ImageMimeType; } contex.Entry(dbEntry).State = System.Data.Entity.EntityState.Modified; } contex.SaveChanges(); }