public async Task <GetResponse <IReadOnlyList <ISalesVerification> > > GetAllSalesVerificationAsync(int auditId, int entityId, string state, int locationId, SalesPeriodType periodType) { var getResponse = new GetResponse <IReadOnlyList <ISalesVerification> >(); try { getResponse = await _salesRepository.GetAllSalesVerificationAsync(auditId, entityId, state, locationId, periodType); } catch (Exception ex) { Console.WriteLine(ex); getResponse.AddError(ex); _logManager.LogError(ex, "Error retrieving saless"); } return(getResponse); }
public async Task <GetResponse <IReadOnlyList <ISalesVerification> > > GetAllSalesVerificationAsync(int auditId, int entityId, string state, int locationId, SalesPeriodType periodType) { var response = new GetResponse <IReadOnlyList <ISalesVerification> >(); try { using (var connection = ConnectionFactory.GetConnection()) { var sql = "spsAllSalesVerification"; var results = await connection .QueryAsync <SalesVerificationDto>(sql, new { AuditId = auditId, EntityId = entityId, LocationId = locationId }, commandType : CommandType.StoredProcedure); var filteredResults = results .Where(dto => dto.State == state && dto.PeriodType == (int)periodType) .AsList(); var items = filteredResults .Select(dto => dto.ToModel()) .AsList(); foreach (var dto in filteredResults) { if (dto.VerificationFileId.HasValue) { var fileResult = await _auditUploadRepository.GetByIdAsync(dto.VerificationFileId.Value); if (fileResult.IsSuccessful) { items.First(i => i.PeriodStart == dto.PeriodStart) .VerificationFile = fileResult.Content; } } } response.Content = items; } } catch (Exception e) { var messaage = $@"Unable to retrieve sales records."; response.AddError(e); LogManager.LogError(e, messaage); Console.WriteLine(e); } return(response); }
public async Task <GetResponse <IReadOnlyList <ISales> > > GetAllSalesAsync(int auditId, int entityId, int locationId, SalesPeriodType periodType) { var getResponse = new GetResponse <IReadOnlyList <ISales> >(); try { getResponse = await _salesRepository.GetAllSalesAsync(auditId, entityId, periodType); if (getResponse.IsSuccessful) { getResponse.Content = getResponse.Content .Where(s => s.LocationId == locationId) .ToList(); } } catch (Exception ex) { Console.WriteLine(ex); getResponse.AddError(ex); _logManager.LogError(ex, "Error retrieving saless"); } return(getResponse); }
public async Task <GetResponse <IReadOnlyList <ISales> > > GetAllSalesAsync(int auditId, int entityId, SalesPeriodType periodType) { var response = new GetResponse <IReadOnlyList <ISales> >(); try { using (var connection = ConnectionFactory.GetConnection()) { var sql = $@"spsAllSales"; var results = await connection.QueryAsync <SalesDto>(sql, new { AuditId = auditId, EntityId = entityId }, commandType : CommandType.StoredProcedure); response.Content = results .Where(dto => dto.PeriodType == (int)periodType) .Select(dto => dto.ToModel()) .AsList(); } } catch (Exception e) { var messaage = $@"Unable to retrieve sales records."; response.AddError(e); LogManager.LogError(e, messaage); Console.WriteLine(e); } return(response); }