private TrackingResponseDto CreateTrackingNotificationImpl(IRepositoryLocator locator, TrackingNotificationDto dto) { var response = new TrackingResponseDto { Accepted = false, NotificationId = dto.Id, DispatchNoteId = 0, Error = string.Empty }; // see if we can fetch dispatch note var dispatchNote = locator.FindAll<DispatchNote>() .FirstOrDefault(d => d.TruckReg.Equals(dto.TruckRegistration, StringComparison.InvariantCultureIgnoreCase)); var allDispatches = locator.FindAll<DispatchNote>().ToList(); var xx = allDispatches; if (dispatchNote == null) { response.Error = "DispatchNote was not found with Truck Registration: " + dto.TruckRegistration; return response; } response.DispatchNoteId = dispatchNote.Id; // dispatch found and it is valid return dispatchNote.CreateTrackingNotification(locator, dto, response); }
private TrackingResponseDto CreateTrackingNotificationImpl(IRepositoryLocator locator, TrackingNotificationDto dto) { var response = new TrackingResponseDto { Accepted = false, NotificationId = dto.Id, DispatchNoteId = 0, Error = string.Empty }; // see if we can fetch dispatch note var dispatchNote = locator.FindAll <DispatchNote>() .FirstOrDefault(d => d.TruckReg.Equals(dto.TruckRegistration, StringComparison.InvariantCultureIgnoreCase)); if (dispatchNote == null) { response.Error = "DispatchNote was not found with Truck Registration: " + dto.TruckRegistration; return(response); } response.DispatchNoteId = dispatchNote.Id; // dispatch found and it is valid response = dispatchNote.CreateTrackingNotification(locator, dto, response); if (response.Accepted) { var dispatchEvent = Mapper.Map <DispatchEventBase>(dispatchNote); CreateDispatchEvent(dispatchEvent); } return(response); }
private DtoResponse CheckOnlyOneCustomer(IRepositoryLocator locator) { var customers = locator.FindAll <Customer>().Where(c => c.FirstName == "TestName").ToList(); Assert.AreEqual(1, customers.Count); return(new DtoResponse()); }
public CustomerDtos FindAllCommand(IRepositoryLocator locator) { var customers = locator.FindAll<Customer>(); var result = new CustomerDtos { Customers = new List<CustomerDto>() }; if (!customers.Any()) return result; customers.ToList().ForEach(c => result.Customers.Add(CustomerToDto(c))); return result; }
private List<DispatchNoteDto> GetActiveDispatchNotesImpl(IRepositoryLocator locator) { var results = locator.FindAll<DispatchNote>() .Where( d => d.DispatchNoteStatus.Equals(DispatchNote.New) || d.DispatchNoteStatus.Equals(DispatchNote.InTransit)).ToList(); return Mapper.Map<List<DispatchNoteDto>>(results); }
private List <DispatchNoteDto> GetActiveDispatchNotesImpl(IRepositoryLocator locator) { var results = locator.FindAll <DispatchNote>() .Where( d => d.DispatchNoteStatus.Equals(DispatchNote.New) || d.DispatchNoteStatus.Equals(DispatchNote.InTransit)).ToList(); return(Mapper.Map <List <DispatchNoteDto> >(results)); }
private CustomerDtos FindAllCommand(IRepositoryLocator locator) { var result = new CustomerDtos { Customers = new List <CustomerDto>() }; locator.FindAll <Customer>().ToList() .ForEach(c => result.Customers.Add(Customer_to_Dto(c))); return(result); }
private static void CheckForDuplicates(IRepositoryLocator locator, CustomerDto op) { var result = locator.FindAll <Customer>().Where(c => c.FirstName == op.FirstName && c.LastName == op.LastName && c.Id != op.Id).ToArray(); if (!result.Any()) { return; } throw new BusinessException(BusinessExceptionEnum.Validation, "A customer instance already exist with these first and last names."); }
private CustomerDtos FindAllCommand(IRepositoryLocator locator) { var result = new CustomerDtos { Customers = new List <CustomerDto>() }; var customers = locator.FindAll <Customer>().ToList(); result.Customers = Mapper.Map <List <Customer>, List <CustomerDto> >(customers); if (result.Customers.Count() == 0) { BusinessNotifier.AddWarning(BusinessWarningEnum.Default, "No customer instances were found"); } return(result); }
private DtoResponse DeleteTestCustomer(IRepositoryLocator locator) { var customers = locator.FindAll <Customer>().Where(c => c.FirstName == "TestName").ToList(); foreach (var customer in customers) { foreach (var address in customer.Addresses()) { customer.DeleteAddress(locator, address.Id); } locator.Remove(customer); } return(new DtoResponse()); }
private CustomerDtos FindAllCommand(IRepositoryLocator locator) { var result = new CustomerDtos { Customers = new List <CustomerDto>() }; locator.FindAll <Customer>().ToList() .ForEach(c => result.Customers.Add(Customer_to_Dto(c))); if (result.Customers.Count() == 0) { Container.RequestContext.Notifier.AddWarning( BusinessWarningEnum.Default, "No customer instances were found"); } return(result); }
private static void CheckForDuplicates(IRepositoryLocator locator, AddressDto op) { var result = locator.FindAll <Address>().Where(a => a.Customer.Id == op.CustomerId && a.Street == op.Street && a.City == op.City && a.PostCode == op.PostCode && a.Country == op.Country && a.Id != op.Id); if (!result.Any()) { return; } throw new BusinessException(BusinessExceptionEnum.Validation, "An address instance for this customer already exist with the same details."); }
private DispatchNoteModel GetLastDispatchImpl(IRepositoryLocator locator) { var entity = locator.FindAll<DispatchNote>().OrderByDescending(d => d.CreationDate).FirstOrDefault(); return Mapper.Map<DispatchNote, DispatchNoteModel>(entity); }
private List<DispatchNoteModel> GetDispatchesBetweenDatesImpl(IRepositoryLocator locator, DateTime startDate, DateTime endDate) { var dispatches = locator.FindAll<DispatchNote>().Where(d => d.CreationDate >= startDate && d.CreationDate <= endDate).ToList(); return Mapper.Map<List<DispatchNote>, List<DispatchNoteModel>>(dispatches); }
private IEnumerable<DispatchNoteModel> GetAllDispatchesImpl(IRepositoryLocator locator) { var instances = locator.FindAll<DispatchNote>().ToList(); return Mapper.Map<List<DispatchNote>, List<DispatchNoteModel>>(instances); }
private List <DispatchNoteModel> GetDispatchesBetweenDatesImpl(IRepositoryLocator locator, DateTime startDate, DateTime endDate) { var dispatches = locator.FindAll <DispatchNote>().Where(d => d.CreationDate >= startDate && d.CreationDate <= endDate).ToList(); return(Mapper.Map <List <DispatchNote>, List <DispatchNoteModel> >(dispatches)); }
private DispatchNoteModel GetLastDispatchImpl(IRepositoryLocator locator) { var entity = locator.FindAll <DispatchNote>().OrderByDescending(d => d.CreationDate).FirstOrDefault(); return(Mapper.Map <DispatchNote, DispatchNoteModel>(entity)); }
private IEnumerable <DispatchNoteModel> GetAllDispatchesImpl(IRepositoryLocator locator) { var instances = locator.FindAll <DispatchNote>().ToList(); return(Mapper.Map <List <DispatchNote>, List <DispatchNoteModel> >(instances)); }
private static HaulierModel GetHaulierByName(IRepositoryLocator locator, string haulierName) { var instance = locator.FindAll <Haulier>().Single(h => h.Name == haulierName); return(Mapper.Map <Haulier, HaulierModel>(instance)); }