Beispiel #1
0
        public async Task AddMedia(MediaAbs media)
        {
            await m_library.AddMediaToLibrary(media);

            if (media.UsingPerson != null)
            {
                await m_mediaStatictics.RegisterMedia(media.Id, media.UsingPerson);
            }
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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));
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        public async Task <bool> IsMediaInUse(MediaAbs media)
        {
            MediaAbs selectedMedia = await GetMediaById(media.Id);

            return(selectedMedia.IsInUse());
        }
Beispiel #8
0
 public async Task AddMediaToLibrary(MediaAbs media)
 {
     _myMedia.Add(media);
 }