コード例 #1
0
        public async Task <StoreClosingDateDto> CreateClosingDateAsync(int branchId, DateTime closingDate)
        {
            var storeBranchE = await Repository.FindAsync(branchId) ?? throw new EntityNotFoundException();

            var storeClosingDateE = await StoreClosingDateRepository
                                    .FindAsync(e =>
                                               e.StoreBranchID == branchId &&
                                               e.ClosingDate.Year == closingDate.Year &&
                                               e.ClosingDate.Month == closingDate.Month &&
                                               e.ClosingDate.Day == closingDate.Day);

            if (storeClosingDateE != null)
            {
                throw new BusinessException();
            }

            var yesterday = DateTime.Now.Subtract(TimeSpan.FromDays(1)).ClearTime();
            var cDate     = closingDate.ClearTime();

            if (DateTime.Compare(cDate, yesterday) <= 0)
            {
                throw new BusinessException();
            }

            storeClosingDateE = await StoreClosingDateRepository.InsertAsync(new StoreClosingDateEntity(branchId, closingDate), true);

            return(ObjectMapper.Map <StoreClosingDateEntity, StoreClosingDateDto>(storeClosingDateE));
        }
コード例 #2
0
        public async Task <StoreClosingDateDto[]> GetAllClosingDateAsync(int branchId)
        {
            var eList = await AsyncExecuter.ToListAsync(StoreClosingDateRepository.Where(e => e.StoreBranchID == branchId));

            return(ObjectMapper.Map <StoreClosingDateEntity[], StoreClosingDateDto[]>(eList.ToArray())
                   .OrderBy(dto => dto.ClosingDate)
                   .ToArray());
        }
コード例 #3
0
 public async Task DeleteClosingDateAsync(int Id)
 {
     await StoreClosingDateRepository.DeleteAsync(Id);
 }