//: BaseService, IContentAdminService { // ************************************** // Update // ************************************** public static void Update(Content contentModel, IList<int> tagsModel, IDictionary<TagType, string> newTagsModel, IList<ContentRepresentationUpdateModel> representationModel) { using (var ctx = new SongSearchContext()) { //UpdateModelWith Content var content = ctx.Contents .Include("Tags") .Include("Catalog") .Include("ContentRepresentations") .Include("ContentRepresentations.Territories") .Where(c => c.ContentId == contentModel.ContentId).SingleOrDefault();// && user.UserCatalogRoles.Any(x => x.CatalogId == c.CatalogId)).SingleOrDefault(); if (content == null) { throw new ArgumentOutOfRangeException("Content does not exist"); } content.UpdateModelWith(contentModel); //UpdateModelWith Tags tagsModel = tagsModel.Where(t => t > 0).ToList(); // create new tags var newTags = ctx.CreateTags(newTagsModel); tagsModel = tagsModel.Union(newTags).ToList(); // add to tagsModel content = ctx.UpdateTags(content, tagsModel); //UpdateModelWith Representation content = ctx.UpdateRepresentation(content, representationModel); content.LastUpdatedByUserId = Account.User().UserId; content.LastUpdatedOn = DateTime.Now; ctx.SaveChanges(); CacheService.InitializeApp(true); //CacheService.CacheUpdate(CacheService.CacheKeys.Content); //CacheService.CacheUpdate(CacheService.CacheKeys.Rights); //CacheService.CacheUpdate(CacheService.CacheKeys.TopTags); //CacheService.CacheUpdate(CacheService.CacheKeys.Tags); //CacheService.CacheUpdate(CacheService.CacheKeys.Territories); } }