Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
 public async Task <int> Update(EventAlbum eventAlbum)
 {
     return(await Context.SaveChangesAsync());
 }
Exemplo n.º 3
0
 public async Task <int> Insert(EventAlbum eventAlbum)
 {
     _eventAlbumRepository.Create(eventAlbum);
     return(await Context.SaveChangesAsync());
 }