Пример #1
0
        public async Task <IActionResult> UpdateAlbum(string id, string albumId, [FromBody] EventAlbumMeta eventAlbum)
        {
            eventAlbum.Album.TenantId = CurrentUser.TenantId;
            eventAlbum.Album.UserId   = CurrentUser.Id;
            eventAlbum.Album.FullName = CurrentUser.FullName;
            eventAlbum.Album.Avatar   = CurrentUser.Avatar;
            var result = await _eventAlbumService.Update(CurrentUser.TenantId, id, albumId, eventAlbum);

            if (result.Code <= 0)
            {
                return(BadRequest(result));
            }

            return(Ok(result));
        }
Пример #2
0
        public async Task <ActionResultResponse <string> > Insert(string tenantId, string eventId, EventAlbumMeta eventAlbumMeta)
        {
            var apiUrls = _configuration.GetApiUrl();

            if (apiUrls == null)
            {
                return(new ActionResultResponse <string>(-1, _sharedResourceService.GetString("Missing some configuration. Please contact with administrator.")));
            }

            var resultInsertAlbum = await new HttpClientService()
                                    .PostAsync <ActionResultResponse <string> >($"{apiUrls.WebsiteApiUrl}/albums/client", eventAlbumMeta.Album);

            if (resultInsertAlbum == null || resultInsertAlbum?.Code <= 0)
            {
                return(new ActionResultResponse <string>(-2, _sharedResourceService.GetString(ErrorMessage.SomethingWentWrong)));
            }

            var eventAlbum = new EventAlbum()
            {
                Id       = Guid.NewGuid().ToString(),
                TenantId = tenantId,
                EventId  = eventId,
                AlbumId  = resultInsertAlbum.Data,
                IsActive = true
            };

            var result = await _eventAlbumRepository.Insert(eventAlbum);

            if (result <= 0)
            {
                await DeleteAlbum(tenantId, resultInsertAlbum.Data);

                return(new ActionResultResponse <string>(-2, _sharedResourceService.GetString(ErrorMessage.SomethingWentWrong)));
            }

            return(new ActionResultResponse <string>(result, _sharedResourceService.GetString("Insert album success"), "", eventAlbum.Id));
        }
Пример #3
0
        public async Task <ActionResultResponse> Update(string tenantId, string eventId, string albumId, EventAlbumMeta eventAlbumMeta)
        {
            var eventAlbumInfo = await _eventAlbumRepository.GetInfo(tenantId, eventId, albumId);

            if (eventAlbumInfo == null)
            {
                return(new ActionResultResponse(-1, _websiteEventResourceService.GetString("Event Album not exists")));
            }

            var apiUrls = _configuration.GetApiUrl();

            return(await new HttpClientService()
                   .PostAsync <ActionResultResponse>($"{apiUrls.WebsiteApiUrl}/albums/client/{tenantId}/update/{albumId}", eventAlbumMeta.Album));
        }