public async Task AddMedia(MediaAbs media) { await m_library.AddMediaToLibrary(media); if (media.UsingPerson != null) { await m_mediaStatictics.RegisterMedia(media.Id, media.UsingPerson); } }
private async Task SetUsingPersonIfNeede(MediaAbs media, string usingPerson) { if (usingPerson != null) { Guid UsingPersonId = Guid.Parse(usingPerson); Person person = await m_mediaService.GetPersonById(UsingPersonId); media.SetUsingPerson(person); } }
public async Task <IActionResult> UpdateMedia([FromBody] MediaRequest mediaRequest) { MediaAbs media = await m_mediaFactory.CreateMedia(mediaRequest); if (media == null) { return(BadRequest(new { Error = "Media Type Not Found" })); } var updated = await m_mediaService.UpdateMedia(media, mediaRequest.Id); if (!updated) { return(NotFound()); } return(Ok(media)); }
public async Task <bool> ChangeMedia(MediaAbs media, string id) { MediaAbs selectedMedia = await GetMediaById(Guid.Parse(id)); if (selectedMedia != null) { selectedMedia.Date = media.Date; selectedMedia.EventType = media.EventType; selectedMedia.Location = media.Location; selectedMedia.Participants = media.Participants; selectedMedia.UsingPerson = media.UsingPerson; selectedMedia.Name = media.Name; return(true); } return(false); }
public async Task <IActionResult> AddMedia([FromBody] MediaRequest mediaRequest) { MediaAbs media = await m_mediaFactory.CreateMedia(mediaRequest); if (media == null) { return(BadRequest(new { Error = "Media Type Not Found" })); } await m_mediaService.AddMedia(media); var baseUri = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}://media"; var locationUrl = baseUri + "/" + media.Id.ToString(); var response = new MediaResponse() { Name = media.Name, Id = media.Id }; return(Created(locationUrl, response)); }
public async Task <bool> UpdateMedia(MediaAbs media, string id) { Guid mediaId = Guid.Parse(id); var currentMedia = await m_library.GetMediaById(mediaId); var changedUsingPerson = currentMedia.UsingPerson != media.UsingPerson; var updated = await m_library.ChangeMedia(media, id); if (!updated) { return(false); } var mediaStatUpdated = true; if (changedUsingPerson) { await m_mediaStatictics.UnRegisterMedia(mediaId); await m_mediaStatictics.RegisterMedia(mediaId, media.UsingPerson); } return(mediaStatUpdated); }
public async Task <bool> IsMediaInUse(MediaAbs media) { MediaAbs selectedMedia = await GetMediaById(media.Id); return(selectedMedia.IsInUse()); }
public async Task AddMediaToLibrary(MediaAbs media) { _myMedia.Add(media); }