private CustomerDto UpdateCustomerCommand(IRepositoryLocator locator, CustomerDto dto) { var instance = locator.GetById <Customer>(dto.Id); instance.Update(locator, dto); return(Customer_to_Dto(instance)); }
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; }
public Query UpdateQuery(IRepositoryLocator locator, Query updatedQuery) { var parameters = ExtractParameters(updatedQuery); updatedQuery.AssociateParameters(parameters); return locator.Update(updatedQuery); }
private DispatchNoteModel SaveDispatchImpl(IRepositoryLocator locator, DispatchNoteModel dispatchModel) { var entity = DispatchNote.Create(locator, dispatchModel); locator.FlushModifications(); // need to flush in order to get the Id into the DTO return(Mapper.Map <DispatchNote, DispatchNoteModel>(entity)); }
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 static AddressDto UpdateAddressCommand(IRepositoryLocator locator, AddressDto dto) { var address = locator.GetById <Address>(dto.Id); address.Update(locator, dto); return(AddressToAddressDto(address)); }
public virtual TEntityDto CreateNewCommand(IRepositoryLocator locator, TEntityDto entityDto, string userName) { PopulateChildObjects = true; TEntity entity = EntityDtoToEntity(entityDto); //checks for the valid object and adds warnings/validation rules to Request object CheckForValidations(entity); TEntityDto result; if ((AllowSaveWithWarnings && IsValidForBasicMandatoryFields) || IsValid) { PopulateChildObjects = false; locator.GetRepository <TEntity>().Add(entity); LoggingFactory.LogInfo("Created " + typeof(TEntity).Name + " : Id : "); string description = "Created " + typeof(TEntity).Name + " : " + GetEntityInstanceName(entity); LoggActivity(description, userName); } else { string description = "Failed to create " + typeof(TEntity).Name + " : " + GetEntityInstanceName(entity); LoggingFactory.LogInfo(description); //LoggActivity(description, loggedInUserDto); } //if (populateChildObjects != null) // PopulateChildObjects = Convert.ToBoolean(populateChildObjects); PopulateChildObjects = false; result = EntityToEntityDto(entity); return(result); }
public static TrackingNotification Create(IRepositoryLocator locator, TrackingNotificationDto dto, DispatchNote dispatchNote) { var instance = Mapper.Map <TrackingNotification>(dto); instance.DispatchNote = dispatchNote; return(locator.Save(instance)); }
public override EntityDtos <CityVillageDto> FindByQueryCommand(IRepositoryLocator locator, Query query) { Criterion criteriaBaseCVIdNotNull = new Criterion(Constants.BASECVID, null, CriteriaOperator.IsNotNullOrZero); Criterion criteriaCAId = new Criterion(Constants.CAID, query.CAId, CriteriaOperator.Equal); Query query1 = new Query(); query1.Add(criteriaCAId); query1.Add(criteriaBaseCVIdNotNull); IQueryable <CityVillage> caCVListWithBaseCVId = locator.GetRepository <CityVillage>().FindBy(query1); IQueryable <CityVillage> CityVillageList = locator.GetRepository <CityVillage>().FindBy(query); //CityVillageList = CityVillageList.Except(caCVListWithBaseCVId); var itemIds = caCVListWithBaseCVId.Select(x => x.BaseCityVillageId).ToArray(); CityVillageList = CityVillageList.Where(x => !itemIds.Contains(x.CityVillageId)); IList <CityVillageDto> allDto = new List <CityVillageDto>(); foreach (CityVillage entity in CityVillageList) { allDto.Add(EntityToEntityDto(entity)); } var result = new EntityDtos <CityVillageDto> { Entities = allDto }; result.TotalRecords = locator.GetRepository <CityVillage>().GetCount(query); if (result.TotalRecords == 0) { Container.RequestContext.Notifier.AddWarning(BusinessWarningEnum.Default, "No records were found"); } return(result); }
public DispatchLine AddLine(IRepositoryLocator locator, DispatchLineModel dispatchLineModel) { var line = DispatchLine.Create(locator, dispatchLineModel); DispatchLineSet.Add(line); return(line); }
private CustomerDto CreateNewCustomerCommand(IRepositoryLocator locator, CustomerDto dto) { var customer = Customer.Create(locator, dto); //Thread.Sleep(10000); return(Customer_to_Dto(customer)); }
private DtoResponse DeleteAddressCommand(IRepositoryLocator locator, long customerId, long addressId) { var customer = locator.GetById <Customer>(customerId); customer.DeleteAddress(locator, addressId); return(new DtoResponse()); }
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 virtual TEntityDto UpdateCommand(IRepositoryLocator locator, TEntityDto entityDto, string userName) { string description = string.Empty; PopulateChildObjects = true; TEntity entityInstance = EntityDtoToEntity(entityDto); if (userName != null) { CheckForValidationsWhileUpdating(entityInstance); if ((AllowSaveWithWarnings && IsValidForBasicMandatoryFields) || IsValid) { locator.GetRepository <TEntity>().Update(entityInstance); description = "Updated " + typeof(TEntity).Name + " : " + GetEntityInstanceName(entityInstance); LoggActivity(description, userName); } else { description = "Failed to create " + typeof(TEntity).Name + " : " + GetEntityInstanceName(entityInstance); LoggingFactory.LogInfo(description); } } else { locator.GetRepository <TEntity>().Update(entityInstance); description = "Failed to Login " + typeof(TEntity).Name + " : " + GetEntityInstanceName(entityInstance); LoggingFactory.LogInfo(description); Container.RequestContext.Notifier.AddWarning(BusinessWarningEnum.Validation, "Invalid Username or Password"); } //if(populateChildObjects!=null) //PopulateChildObjects = Convert.ToBoolean(populateChildObjects); PopulateChildObjects = false; return(EntityToEntityDto(entityInstance)); }
protected static void ValidateOperation(IRepositoryLocator locator, ValidatorDtoBase operation) { if (operation.IsValid()) { return; } throw new BusinessException(BusinessExceptionEnum.Validation, operation.Error); }
private ActivityLogDto CreateNewCommand(IRepositoryLocator locator, ActivityLogDto entityDto, string userName) { ActivityLog logInstance = Mapper.Map <ActivityLogDto, ActivityLog>(entityDto); locator.GetRepository <ActivityLog>().Add(logInstance); LoggingFactory.LogInfo("ActivityLog Created with ID :" + logInstance.LogId.ToString()); return(Mapper.Map <ActivityLog, ActivityLogDto>(logInstance)); }
private void AddAddressValidate(IRepositoryLocator locator, AddressDto operation) { if (operation.CustomerId.Equals(Id)) { return; } throw new BusinessException(BusinessExceptionEnum.Validation, "Incorrect Customer Id was passed with the address details"); }
public virtual void DeleteAddress(IRepositoryLocator locator, long addressId) { DeleteAddressValidate(locator, addressId); var address = AddressSet.Single(a => a.Id.Equals(addressId)); AddressSet.Remove(address); locator.Remove(address); }
public virtual Address AddAddress(IRepositoryLocator locator, AddressDto operation) { AddAddressValidate(locator, operation); var address = Address.Create(locator, operation); AddressSet.Add(address); return(address); }
public void Update(IRepositoryLocator locator, CustomerDto operation) { UpdateValidate(locator, operation); FirstName = operation.FirstName; LastName = operation.LastName; Telephone = operation.Telephone; locator.Update(this); }
public SchoolQueryService(IAmbientDbContextLocator dbContextLocator, IRepositoryLocator repositoryLocator) { Guard.AgainstNull(dbContextLocator, nameof(dbContextLocator)); Guard.AgainstNull(repositoryLocator, nameof(repositoryLocator)); this.dbContextLocator = dbContextLocator; this.repositoryLocator = repositoryLocator; }
public static Haulier Create(IRepositoryLocator locator, HaulierModel model) { var instance = new Haulier { Name = model.Name }; locator.Save(instance); return(instance); }
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; }
public virtual void Update(IRepositoryLocator locator, AddressDto operation) { UpdateValidate(locator, operation); Street = operation.Street; City = operation.City; PostCode = operation.PostCode; Country = operation.Country; locator.Update(this); }
public virtual void Update(IRepositoryLocator locator, CustomerDto operation) { ValidateOperation(locator, operation); CheckForDuplicates(locator, operation); FirstName = operation.FirstName; LastName = operation.LastName; Telephone = operation.Telephone; locator.Update(this); }
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)); }
public Query AddQuery(IRepositoryLocator locator,Query newQuery,string userName) { //Resolve windows user name to qt user var chris = locator.GetById<User>(1); var parameters = ExtractParameters(newQuery); newQuery.AssociateParameters(parameters); return locator.Save(AddDefaultProperties(newQuery,chris)); }
private static void CreateUsersFromCsv(IRepositoryLocator locator) { var loader = new EntityLoader<User>("user.csv"); var users = loader.LoadEntities(); foreach (var user in users) { locator.Save(user); } }
private DtoResponse DeleteAddressCommand(IRepositoryLocator locator, long id) { var address = locator.GetById <Address>(id); BusinessNotifier.AddWarning(BusinessWarningEnum.Default, string.Format("Address with id:{0} was deleted", address.Id)); locator.Remove(address); 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))); return(result); }
private DtoResponse DeleteCommand(IRepositoryLocator locator, long id) { var TEntity = locator.GetById <TEntity>(id); //BusinessNotifier.AddWarning (BusinessWarningEnum.Default, // string.Format ("TEntity with id:{0} was deleted", // TEntity.Id)); //string description = "Deleted " + typeof(TEntity).Name + " : " + GetEntityInstanceName(TEntity); //LoggActivity(description, loggedInUserDto); locator.Remove(TEntity); return(new DtoResponse()); }
public static Customer Create(IRepositoryLocator locator, CustomerDto operation) { var instance = new Customer { FirstName = operation.FirstName, LastName = operation.LastName, Telephone = operation.Telephone }; locator.Save(instance); return instance; }
public static Customer Create(IRepositoryLocator locator, CustomerDto operation) { var instance = new Customer { FirstName = operation.FirstName, LastName = operation.LastName, Telephone = operation.Telephone }; locator.Save(instance); return(instance); }
private DtoResponse DeleteCustomerCommand(IRepositoryLocator locator, long id) { var customer = locator.GetById <Customer>(id); BusinessNotifier.AddWarning(BusinessWarningEnum.Default, string.Format("Customer {0} {1} [id:{2}] was deleted", customer.FirstName, customer.LastName, customer.Id)); locator.Remove(customer); return(new DtoResponse()); }
private EntityDtos <TEntityDto> FindAllCommand(IRepositoryLocator locator) { IQueryable <TEntity> all = locator.GetRepository <TEntity>().FindAll(); var result = new EntityDtos <TEntityDto> { Entities = Mapper.Map <IQueryable <TEntity>, List <TEntityDto> >(all) }; if (result.Entities.Count() == 0) { Container.RequestContext.Notifier.AddWarning(BusinessWarningEnum.Default, "No Users were found"); } 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 static void Create2Users(IRepositoryLocator locator) { var user = new User() { Name = "Chris Ranasinghe", }; locator.Save(user); var user2 = new User() { Name = "Anil De Silva", }; locator.Save(user2); }
private static void CreateQueries(IRepositoryLocator locator) { var user = locator.FetchAll<User>().FirstOrDefault(); if (user == null) throw new InvalidDataException("User is needed before creating query"); var q1 = new Query { CreatedDateTime = DateTime.Now, DbType = EnumDatabase.Oracle, Description = "Test Query - User Permissions", DisplayOnHomeScreen = true, Name = "RPO - Permissions", Text = "select p.description as User_Or_Group, r.description as RpoMS_Role from role r,principal p,role_principal rp where r.id = rp.role_id and p.id = rp.principal_id", Owner = user, ParameterCount = 0, Published = true }; var q2 = new Query { CreatedDateTime = DateTime.Now, DbType = EnumDatabase.Oracle, Description = "Test Query - Rail Requirement Manager", Text = "Select * from Query", DisplayOnHomeScreen = true, Name = "RPO - Rail Req", Owner = user, ParameterCount = 1, Published = true }; var q3 = new Query { CreatedDateTime = DateTime.Now, DbType = EnumDatabase.Oracle, Description = "Test Query - PIM All sites", Text = "Select * from site", DisplayOnHomeScreen = true, Name = "PIM - sites", Owner = user, ParameterCount = 0, Published = true }; locator.Save(q1); locator.Save(q2); locator.Save(q3); }
private void CreateGroups(IRepositoryLocator locator) { var q1List = locator.FetchAll<Query>().OrderBy(q => q.Id).Take(2).ToList(); var q2List = locator.FetchAll<Query>().OrderByDescending(q => q.Id).Take(2).ToList(); var q1Group = new QueryGroup() { Name = "Group 1", CreatedDateTime = DateTime.Now, }; q1Group.AddQueries(q1List); locator.Save(q1Group); var q2Group = new QueryGroup() { Name = "Group 2", CreatedDateTime = DateTime.Now, }; q2Group.AddQueries(q2List); locator.Save(q2Group); }
public IEnumerable<Query> GetQueryList(IRepositoryLocator locator) { return locator.FetchAll<Query>(); }
public bool DeleteQuery(IRepositoryLocator locator,long id) { var q = locator.GetById<Query>(id); locator.Delete(q); return true; }
private DispatchNoteModel GetLastDispatchImpl(IRepositoryLocator locator) { var entity = locator.FindAll<DispatchNote>().OrderByDescending(d => d.CreationDate).FirstOrDefault(); return Mapper.Map<DispatchNote, DispatchNoteModel>(entity); }
private void UpdateValidate(IRepositoryLocator locator, CustomerDto operation) { return; }
private DispatchNoteModel SaveDispatchImpl(IRepositoryLocator locator, DispatchNoteModel dispatchModel) { var entity = DispatchNote.Create(locator, dispatchModel); locator.FlushModifications(); // need to flush in order to get the Id into the DTO return Mapper.Map<DispatchNote, DispatchNoteModel>(entity); }
public CustomerDto CreateNewCustomerCommand(IRepositoryLocator locator, CustomerDto dto) { var customer = Customer.Create(locator, dto); return CustomerToDto(customer); }
private DispatchNoteModel GetDispathNoteByIdImpl(IRepositoryLocator locator, long id) { var instance = locator.GetById<DispatchNote>(id); return Mapper.Map<DispatchNote, DispatchNoteModel>(instance); }
public CustomerDto GetByIdCommand(IRepositoryLocator locator, long id) { var customer = locator.GetById<Customer>(id); return CustomerToDto(customer); }
public CustomerDto UpdateCustomerCommand(IRepositoryLocator locator, CustomerDto dto) { var instance = locator.GetById<Customer>(dto.CustomerId); instance.Update(locator, dto); return CustomerToDto(instance); }
protected CustomRepository(IRepositoryLocator repositoryLocatorLocator) { _repository = repositoryLocatorLocator.RepositoryInstance; }
public IEnumerable<Query> GetQueryListForGroup(IRepositoryLocator locator,int groupId) { var list = (IEnumerable<Query>)locator.GetById<QueryGroup>(groupId).Queries; return list.AsEnumerable(); }
private IEnumerable<DispatchNoteModel> GetAllDispatchesImpl(IRepositoryLocator locator) { var instances = locator.FindAll<DispatchNote>().ToList(); return Mapper.Map<List<DispatchNote>, List<DispatchNoteModel>>(instances); }
public void Run(IRepositoryLocator locator) { CreateQueries(locator); }
private IEnumerable<Query> GetAllQueries(IRepositoryLocator locator, string desc) { var qr = locator.GetRepository<Query>(); return qr.FetchAll().AsEnumerable(); }
public void Run(IRepositoryLocator locator) { CreateGroups(locator); }
public static TrackingNotification Create(IRepositoryLocator locator, TrackingNotificationDto dto, DispatchNote dispatchNote) { var instance = Mapper.Map<TrackingNotification>(dto); instance.DispatchNote = dispatchNote; return locator.Save(instance); }
public Query AddParameters(IRepositoryLocator locator, long id, List<QueryParameter> parameters ) { var q = locator.GetById<Query>(id); q.AssociateParameters(parameters); return q; }
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); }
public void Run(IRepositoryLocator locator) { Create2Users(locator); }