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)); }
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()); }
public async Task DeleteClosingDateAsync(int Id) { await StoreClosingDateRepository.DeleteAsync(Id); }