public void AddSavedMedia(SavedMedia savedMedia) { try { var savedMediaExists = _unitOfWork.SavedRep.GetById(savedMedia.SavedMediaId); if (savedMediaExists != null) { throw new Exception("This savedMedia is already exists Id:" + savedMedia.SavedMediaId); } _unitOfWork.SavedRep.Insert(savedMedia); _unitOfWork.Save(); } catch (SqlException ex) { throw new Exception(ex.Message); } }
public void AddSavedMedia_WhenCalled_CheckSavedMediaIsUpdated() { var contentId = new Guid("98C2A5E2-F413-4913-BB38-8BD834596713"); var profileId = new Guid("922DB99E-572B-4BEA-91BB-1793F3CD6492"); var media = _mediaManager.GetMediaContent(contentId); if (media != null) { var savedMedia = new SavedMedia() { SavedMediaId = Guid.NewGuid(), Name = media.Title, UserProfileId = profileId, ContentId = media.ContentId }; _savedManager.AddSavedMedia(savedMedia); } }
public void UpdateSavedMedia(SavedMedia savedMedia) { try { var savedMediaExists = _unitOfWork.SavedRep.GetById(savedMedia.SavedMediaId); if (savedMediaExists == null) { throw new Exception("There is no saved media to update with this Id: " + savedMedia.SavedMediaId); } savedMediaExists.Name = savedMedia.Name; savedMediaExists.UserProfileId = savedMedia.UserProfileId; savedMediaExists.ContentId = savedMedia.ContentId; _unitOfWork.SavedRep.Update(savedMediaExists); _unitOfWork.Save(); } catch (SqlException ex) { throw new Exception(ex.Message); } }