public int PatchExecution(TUpdateRequest input) { var getParam = BuildGetParameter(input); _getQuery.BuildQuery(getParam); var existing = _getQueryRunner.Run(_getQuery); if (existing == null) { throw new NotFoundException(); } var updated = _patchEntityAdapter.PatchEnitity <TPayload, TGetEntity, TUpdateParameter> ( existing, input.Payload.Patch ); //then build the query to update the object. _updateQuery.BuildQuery(updated); return(CommandExecutor.ExecuteNonQuery(_updateQuery)); }
public IActionResult UpdateCurrency([FromRoute] CurrencyId id, UpdateCurrencyCommand command) { command.Id = id; try { _commandDispatcher.Dispatch(command); var query = new GetCurrencyQuery { Id = id, }; _queryRunner.Run(query); var queryResult = query.GetResult(); var url = this.Url.Action("GetCurrency", "GetCurrency", new { id }); return(this.Ok(queryResult)); } catch (CurrencyNotFoundException ex) { return(this.NotFoundError(ex)); } catch (CodeAlreadyExistsException ex) { return(this.ConflictError(ex)); } }
private IResultSummary Execute(IQueryRunner runner, string query) { var result = runner.Run(query); Thread.Sleep(_rnd.Next(100)); result.Consume(); Thread.Sleep(_rnd.Next(100)); return result.Consume(); }
public IActionResult GetAllCurrencies() { var query = new GetAllCurrenciesQuery(); _queryRunner.Run(query); var result = query.GetResult(); return(this.Ok(result)); }
public QuoteContract Process(GetQuoteRequest input) { _query.BuildQuery(new GetQuote { Id = input.Id, OrganizationId = input.OrganizationId }); using (DapperUnitOfWork.Begin()) { var quotetask = _runner.Run(_query); var result = QuoteMapper.Map(quotetask); return(result); } }
public JobTaskContract Process(GetJobTaskByIdRequest input) { _query.BuildQuery(new GetJobTask { JobTaskId = input.Id, OrganizationId = input.OrganizationId, JobId = input.JobId }); using (DapperUnitOfWork.Begin()) { var taskDefinition = _runner.Run(_query); var result = JobTaskMapper.Map(taskDefinition); return(result); } }
public InvoiceCostItemContract Process(GetInvoiceCostItemRequest input) { _query.BuildQuery(new GetInvoiceCostItem { Id = input.Id, OrganizationId = input.OrganizationId, InvoiceId = input.InvoiceId }); using (DapperUnitOfWork.Begin()) { var quotecostitem = _runner.Run(_query); var result = InvoiceCostItemMapper.Map(quotecostitem); return(result); } }
public JobDetailsContract Process(GetJobByIdRequest input) { var parameter = new GetJob { OrganizationId = input.OrganizationId, JobId = input.Id }; _query.BuildQuery(parameter); using (DapperUnitOfWork.Begin()) { var job = _runner.Run(_query); var result = JobMapper.Map(job); return(result); } }
public InvoiceContract Process(OrganizationEntityRequest input) { var parameter = new GetOrganizationEntity { OrganizationId = input.OrganizationId, Id = input.Id }; _query.BuildQuery(parameter); using (DapperUnitOfWork.Begin()) { var invoice = _runner.Run(_query); var result = InvoiceMapper.Map(invoice); return(result); } }
public ContactContract Process(GetContactRequest input) { var parameter = new GetContact { OrganizationId = input.OrganizationId, Id = input.Id }; _query.BuildQuery(parameter); using (DapperUnitOfWork.Begin()) { var contact = _runner.Run(_query); var result = ContactMapper.Map(contact); return(result); } }
public TaskDefinitionContract Process(GetTaskDefinitionByIdRequest input) { var parameter = new GetTaskDefinition { OrganizationId = input.OrganizationId, TaskDefinitionId = input.Id }; _query.BuildQuery(parameter); using (DapperUnitOfWork.Begin()) { var taskDefinition = _runner.Run(_query); var result = TaskDefinitionMapper.Map(taskDefinition); return(result); } }
public CustomerContract Process(GetCustomerRequest input) { var parameter = new GetCustomer { OrganizationId = input.OrganizationId, CustomerId = input.Id }; _query.BuildQuery(parameter); using (DapperUnitOfWork.Begin()) { var customer = _runner.Run(_query); var result = CustomerMapper.Map(customer); return(result); } }
public StaffContract Process(GetStaffRequest input) { var parameter = new GetStaff { OrganizationId = input.OrganizationId, Id = input.Id }; _query.BuildQuery(parameter); using (DapperUnitOfWork.Begin()) { var staff = _runner.Run(_query); var result = StaffMapper.Map(staff); return(result); } }
public OAuthClientContract Process(GetOAuthClientRequest input) { var parameter = new GetAuthClient { ClientId = input.ClientId, ClientSecret = input.ClientSecret, IsInternal = input.IsInternal }; using (DapperUnitOfWork.Begin()) { _query.BuildQuery(parameter); var client = _runner.Run(_query); var result = OAuthClientMapper.Map(client); return(result); } }
public JobTimesheetContract Process(GetJobTimesheetRequest input) { var parameter = new GetJobTimesheet { OrganizationId = input.OrganizationId, Id = input.Id, JobId = input.JobId }; _query.BuildQuery(parameter); using (DapperUnitOfWork.Begin()) { var jobTimesheet = _runner.Run(_query); var result = JobTimesheetMapper.Map(jobTimesheet); return(result); } }
public CustomerAddressContract Process(GetCustomerAddressRequest input) { var parameter = new GetCustomerAddress { OrganizationId = input.OrganizationId, CustomerId = input.CustomerId, IsDeleted = input.IsDeleted ?? false, Id = input.Id }; _query.BuildQuery(parameter); using (DapperUnitOfWork.Begin()) { var contact = _runner.Run(_query); var result = AddressMapper.Map(contact); return(result); } }
public JobCostItemContract Process(GetJobCostItemRequest input) { var parameter = new GetJobCostItem { OrganizationId = input.OrganizationId, JobId = input.JobId, Id = input.Id }; _query.BuildQuery(parameter); using (DapperUnitOfWork.Begin()) { var entity = _runner.Run(_query); var result = JobCostItemMapper.Map(entity); return(result); } }
public IActionResult CreateCurrency(CreateCurrencyCommand command) { try { _commandDispatcher.Dispatch(command); } catch (CodeAlreadyExistsException ex) { return(this.ConflictError(ex)); } var id = command.GetResult(); var query = new GetCurrencyQuery { Id = id, }; _queryRunner.Run(query); var queryResult = query.GetResult(); var url = this.Url.Action("GetCurrency", "GetCurrency", new { id }); return(this.Created(url, queryResult)); }
private int ProcessDeFacto(CreateStaffRequest input) { //check staff with the same login exists or not _getStaffByLogin.BuildQuery(new GetStaffByLoginEmail { Email = input.Payload.Email, OrganizationId = input.OrganizationId }); var alreadyCreatedStaff = _queryRunner.Run(_getStaffByLogin); if (alreadyCreatedStaff != null) { if (!alreadyCreatedStaff.IsDeleted) { return(0); } //undelete _undeleteStaffCommand.BuildQuery(new UndeleteStaffByLoginEmail { OrganizationId = input.OrganizationId, LoginEmail = input.Payload.Email }); var resultCount = _executor.ExecuteNonQuery(_undeleteStaffCommand); _getStaffQuery.BuildQuery(new GetStaff { OrganizationId = input.OrganizationId, Id = alreadyCreatedStaff.Id }); var staff = _queryRunner.Run(_getStaffQuery); //reset privileges to default AdjustPrivileges(input.OrganizationId, staff.OrganizationUserId); return((resultCount > 0) ? alreadyCreatedStaff.Id : 0); } //TODO: password provider //if not exists, will create one, otherwise use the existing one _createCredential.BuildQuery(new CreateCredential { Email = input.Payload.Email, Password = "******" }); var credentialId = _executor.Execute(_createCredential); _createOrganizationUser.BuildQuery(new CreateOrganizationUser { OrganizationId = input.OrganizationId, CredentialId = credentialId, OrganizationUserTypeId = input.Payload.IsAdmin ? (int)OrganizationUserTypes.Admin : (int)OrganizationUserTypes.Staff }); var orgUserId = _executor.Execute(_createOrganizationUser); _createStaffCommand.BuildQuery(new CreateStaff { OrganizationId = input.OrganizationId, }); _createStaffCommand.BuildQuery(new CreateStaff { OrganizationId = input.OrganizationId, Code = input.Payload.Code, BaseRate = input.Payload.BaseRate, BillableRate = input.Payload.BillableRate, ContactEmail = input.Payload.ContactEmail, Dob = input.Payload.Dob, FirstName = input.Payload.FirstName, Gender = input.Payload.Gender, LastName = input.Payload.LastName, MobilePhone = input.Payload.MobilePhone, OrganizationUserId = orgUserId, OtherName = input.Payload.OtherName }); var staffId = _executor.Execute(_createStaffCommand); AdjustPrivileges(input.OrganizationId, orgUserId); return(staffId); }
public IEnumerable <WorkerUserDTO> GetList(UserFilter filter, OrderInfo orderInfo, ref PageInfo pageInfo) { return(queryRunner.Run(new UserQuery(filter, orderInfo, ref pageInfo))); }