Exemple #1
0
 public async Task AddAsync(LibrarySalesAreaPassPriority item)
 {
     _ = await _dbContext.AddAsync(
         _mapper.Map <Entities.Tenant.LibrarySalesAreaPassPriority>(item,
                                                                    opts => opts.UseEntityCache(_salesAreaByNameCache)),
         post => post.MapTo(item, opts => opts.UseEntityCache(_salesAreaByIdCache)), _mapper)
         .ConfigureAwait(false);
 }
Exemple #2
0
        public async Task UpdateAsync(LibrarySalesAreaPassPriority item)
        {
            var entity = await _dbContext.FindAsync <Entities.Tenant.LibrarySalesAreaPassPriority>(
                new object[] { item?.Uid },
                find => find.IncludeCollection(e => e.SalesAreaPriorities))
                         .ConfigureAwait(false);

            if (entity != null)
            {
                _ = _mapper.Map(item, entity, opts => opts.UseEntityCache(_salesAreaByNameCache));

                _ = _dbContext.Update(entity,
                                      post => post.MapTo(item, opts => opts.UseEntityCache(_salesAreaByIdCache)), _mapper);
            }
        }
Exemple #3
0
        public async Task <IHttpActionResult> SetDefault(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(BadRequest("Invalid Id"));
            }

            LibrarySalesAreaPassPriority libSalesAreaPassPriority = await _librarySalesAreaPassPrioritiesRepository.GetAsync(id);

            if (libSalesAreaPassPriority == null)
            {
                return(NotFound());
            }

            TenantSettings tenantSettings = _tenantSettingsRepository.Get();

            if (tenantSettings != null)
            {
                tenantSettings.DefaultSalesAreaPassPriorityId = id;
                _tenantSettingsRepository.AddOrUpdate(tenantSettings);
            }
            return(Ok());
        }
Exemple #4
0
        public async Task <IHttpActionResult> Delete(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(BadRequest("Invalid Id"));
            }

            LibrarySalesAreaPassPriority libSalesAreaPassPriority = await _librarySalesAreaPassPrioritiesRepository.GetAsync(id);

            if (libSalesAreaPassPriority == null)
            {
                return(NotFound());
            }

            // Check that sales area pass priority being deleted isn't the default
            if (libSalesAreaPassPriority.Uid == GetDefaultSalesAreaPassPriorityId())
            {
                return(new UnprocessableEntityResult(Request));
            }

            await _librarySalesAreaPassPrioritiesRepository.Delete(libSalesAreaPassPriority.Uid).ConfigureAwait(false);

            return(this.NoContent());
        }
 private void SetupLibrarySalesAreaPassPrioritiesRepositoryGetAsyncToReturn(LibrarySalesAreaPassPriority theEntity)
 {
     _ = _librarySalesAreaPassPrioritiesRepository.Setup(a => a.GetAsync(It.IsAny <Guid>())).ReturnsAsync(theEntity);
 }