public async Task CreateAndSendEmailAsync(TenantRequest tenantRequest) { //var connectionString = // "DefaultEndpointsProtocol=https;AccountName=demorrstorageaccount;AccountKey=NXluNSsP4tm+NViZ65rN6eM4V6Eniko9b7NON3M5xZGaDmGMV0LSIsM9CUVdFe+2n5L8vyl4DtdaVZz+JMJ3iA==;EndpointSuffix=core.windows.net"; var model = new NotificationQueueModel() { TenantRequestModel = _modelMapper.CopyFrom(tenantRequest), }; var det = base.GetWorkerDetails(tenantRequest); model.WorkerModel = det == null ? null : _modelMapper.CopyFrom(det); var message = _modelSerializer.Serialize(model); //var connectionString = "UseDevelopmentStorage=true"; //// Instantiate a QueueClient which will be used to create and manipulate the queue //QueueClient queueClient = new QueueClient(connectionString, "service-requests-queue");// "ServiceRequestsQueue"); //// Create the queue //await queueClient.CreateIfNotExistsAsync(); //// Send a message to the queue //await queueClient.SendMessageAsync(message); //Base64Encode(message)); await _queueClient.SendMessage(message); // Async receive the message //QueueMessage[] retrievedMessage = await queueClient.ReceiveMessagesAsync(); //var tr = _modelMappers.CopyFrom(retrievedMessage[0].MessageText); }
public void AddTenantRequest(TenantRequest tTenantRequest) { TableOperation operation = TableOperation.InsertOrReplace(_entityMapper.CopyFrom(tTenantRequest)); var tbl = _dbContext.RequestCloudTable; tbl.Execute(operation); }
public async Task Update(Guid id, TenantRequest request) { if (request == null) { _logger.LogError($"[Update] Argument {nameof(request)} is null"); throw new ArgumentNullException(nameof(request)); } var serviceProviders = await _serviceProviderRepository.GetAsync(); if (serviceProviders.Any(x => x.TenantName.ToLower() == request.Name.ToLower() && x.Id != id)) { _logger.LogError($"[Update] Duplicate parameter: {nameof(request.Name)}"); throw new DuplicateNameException(); } var serviceProvider = serviceProviders.FirstOrDefault(x => x.Id == id); if (serviceProvider == null) { _logger.LogError($"[Update] ServiceProvider with parameter: {nameof(id)} not found"); throw new KeyNotFoundException(nameof(id)); } serviceProvider.TenantName = request.Name; serviceProvider.Phone = request.Phone; await _serviceProviderRepository.UpdateAsync(serviceProvider); }
public object Post(TenantRequest req) { db.Insert(new Tenant { CreatedDate = DateTime.Now }.PopulateWith(req)); return ... }
public async Task UpdateByCompanyId(int companyId, TenantRequest request) { if (request == null) { _logger.LogError($"[Update] Argument {nameof(request)} is null"); throw new ArgumentNullException(nameof(request)); } var tenants = await _tenantRepository.GetAsync(); if (tenants.Any(x => x.TenantName.ToLower() == request.Name.ToLower() && x.Companies.Select(c => c.Id).Contains(companyId))) { _logger.LogError($"[Update] Duplicate parameter: {nameof(request.Name)}"); throw new DuplicateNameException(); } var tenant = tenants.FirstOrDefault(x => x.Companies.Select(c => c.Id).Contains(companyId)); if (tenant == null) { _logger.LogError($"[Update] Tenant with parameter: {nameof(companyId)} not found"); throw new KeyNotFoundException(nameof(companyId)); } tenant.TenantName = request.Name; tenant.Phone = request.Phone; await _tenantRepository.UpdateAsync(tenant); }
public void UpdateTenantRequest(TenantRequest tTenantRequest) { var tbl = _entityMapper.CopyFrom(tTenantRequest); tbl.ETag = "*"; TableOperation operation = TableOperation.Merge(tbl); _dbContext.RequestCloudTable.Execute(operation); if (tTenantRequest.RequestStatus == TenantRequestStatusEnum.Scheduled) { var change = tTenantRequest.RequestChanges.LastOrDefault(x => x.TenantRequestStatus == TenantRequestStatusEnum.Scheduled); if (change?.Command != null) { var command = change.Command as ScheduleServiceWorkCommand; operation = TableOperation.InsertOrReplace(new WorkerRequestTbl(command.WorkerEmailAddress, tTenantRequest.Id) { TenantEmail = tTenantRequest.TenantEmail }); _dbContext.WorkerRequestsCloudTable.Execute(operation); } } }
public object Post(TenantRequest req) { db.Insert(new Tenant { CreatedDate = DateTime.Now }.PopulateWith(req)); return(new { Id = db.GetLastInsertId() }); }
public void WhenIDeclineTheTenantRequest() { //Creating a Class TenantRequest obj = new TenantRequest(); //Creating Method obj.DeclineTenantRequest(); }
public EmailInfo CreateTenantRequestEmail(TenantRequest tenantRequest, Worker worker) { _tenantRequest = tenantRequest; _worker = worker; var message = CreateMessageOnStatusChange(); return(message == null ? null : CreateEmail(message)); }
public void UpdateTenantRequest(TenantRequest tTenantRequest) { var exist = _context.TenantRequestTbl.Find(tTenantRequest.Id); _context.Entry(exist).CurrentValues.SetValues(_entityMapper.CopyFrom(tTenantRequest)); _context.SaveChanges(); }
public object Post(TenantRequest req) { var tenant = new Tenant { CreatedDate = DateTime.Now }.PopulateWith(req); Db.Save(tenant); return(new { Id = tenant.Id }); }
public void UpdateTenantRequest(TenantRequest tTenantRequest) { if (!_requests.ContainsKey(tTenantRequest.Id)) { throw new DomainEntityNotFoundException("tenant_request_not_found", $"Tenant request not found by id: {tTenantRequest} "); } _requests[tTenantRequest.Id] = tTenantRequest; }
public void AddTenantRequest(TenantRequest tTenantRequest) { var filter = Builders <PropertyModel> .Filter.And( Builders <PropertyModel> .Filter.Where(x => x.Id == tTenantRequest.Tenant.PropertyCode), Builders <PropertyModel> .Filter.ElemMatch(x => x.Tenants, c => c.UnitNumber == tTenantRequest.Tenant.UnitNumber)); var update = Builders <PropertyModel> .Update.Push(x => x.Tenants[-1].Requests, _modelMapper.CopyFrom(tTenantRequest)); _properties.FindOneAndUpdate(filter, update); }
public async Task CreateAndSendEmailAsync(TenantRequest tenantRequest, Worker worker) { await Task.CompletedTask; var email = _emailBuilderService.CreateTenantRequestEmail(tenantRequest, worker); if (email != null) { await _emailService.SendEmailAsync(email); } }
public static TenantRequestModel BuildModel(this TenantRequest tenantRequest) { return(new TenantRequestModel() { RequestCode = tenantRequest.Code, RequestStatus = tenantRequest.RequestStatus.ToString().SplitPascalCase(), DateCreated = tenantRequest.DateCreated, RequestTitle = tenantRequest.RequestTitle, }); }
//----- Requests internal TenantRequest CopyFrom(TenantRequestTbl r) { var req = new TenantRequest( CopyFrom(r.Tenant), r.Code, r.RequestStatus, r.DateCreated, r.ID) { RequestChanges = r.RequestChanges == null ? null : DeserializeObject(r.RequestChanges), ServiceWorkOrderCount = r.ServiceWorkOrderCount, }; return(req); }
public TenantRequest CopyFrom(TenantRequestModel r) { var req = new TenantRequest( CopyFrom(r.TenantModel), r.Code, r.RequestStatus, r.DateCreated, r.ID) { RequestChanges = DeserializeEvents(r.RequestChanges), ServiceWorkOrderCount = r.ServiceWorkOrderCount, }; return(req); }
/// <summary> /// 获取租户列表 /// </summary> /// <param name="input"></param> /// <returns></returns> public virtual async Task <PagedResult <TenantDto> > GetListAsync(TenantRequest input) { if (input.Sorting.IsNullOrWhiteSpace()) { input.Sorting = nameof(Tenant.Name); } var count = await TenantRepository.GetCountAsync(input.Filter); var items = await TenantRepository.GetPagedListAsync(input.Page, input.PageSize, input.Sorting); return(new PagedResult <TenantDto>(count, items.MapTo <List <TenantDto> >())); }
public static TenancyDTO ToDTO(this TenantRequest tenant) { TenancyDTO dto = new TenancyDTO { PersonId = tenant.PersonId, UserName = tenant.UserName, From = tenant.From, To = tenant.To, UnitId = tenant.UnitId, NumberOfPeople = tenant.NumberOfPeople }; return(dto); }
internal TenantRequestTbl CopyFrom(TenantRequest req) { return(new TenantRequestTbl() { Code = req.Code, DateCreated = req.DateCreated, ID = req.Id, TenantID = req.Tenant.Id, RequestStatus = req.RequestStatus, RequestChanges = req.RequestChanges == null? null: SerializeObject(req.RequestChanges), ServiceWorkOrderCount = req.ServiceWorkOrderCount }); }
//----- Requests internal TenantRequest CopyFrom(TenantRequestTbl r, TenantTbl tenantTbl, int requestCount, PropertyTbl propertyTbl) { TenantRequestStatusEnum reqStatus = (TenantRequestStatusEnum)Enum.Parse(typeof(TenantRequestStatusEnum), r.RequestStatus); var req = new TenantRequest( CopyFrom(tenantTbl, requestCount, propertyTbl), r.Code, reqStatus, r.DateCreated, r.ID) { RequestChanges = r.RequestChanges == null ? null : DeserializeObject(r.RequestChanges), ServiceWorkOrderCount = r.ServiceWorkOrderCount, }; return(req); }
internal TenantRequestTbl CopyFrom(TenantRequest req) { return(new TenantRequestTbl(req.TenantEmail, req.Code) { DateCreated = req.DateCreated, ID = req.Id, TenantID = req.Tenant.Id, PropertyCode = req.Tenant.Property.Code, UnitNumber = req.Tenant.UnitNumber, RequestStatus = req.RequestStatus.ToString( ), RequestChanges = req.RequestChanges == null? null: SerializeObject(req.RequestChanges), ServiceWorkOrderCount = req.ServiceWorkOrderCount }); }
public TenantRequestModel CopyFrom(TenantRequest req) { return(new TenantRequestModel() { Code = req.Code, DateCreated = req.DateCreated, ID = req.Id, TenantID = req.Tenant.Id, RequestStatus = req.RequestStatus, RequestChanges = SerializeEvents(req.RequestChanges), // req.RequestChanges == null ? null : SerializeObject(req.RequestChanges), ServiceWorkOrderCount = req.ServiceWorkOrderCount, TenantModel = CopyFrom(req.Tenant) }); }
public async Task <IActionResult> Post([FromBody] TenantRequest request) { try { var tenantId = await _tenantService.Create(request); return(Created(HttpContext.Request.GetEncodedUrl(), tenantId)); } catch (ArgumentNullException ex) { return(BadRequest(ex.Message)); } catch (DuplicateNameException ex) { return(Conflict(ex.Message)); } }
protected Worker GetWorkerDetails(TenantRequest tenantRequest) { Worker worker = null; if (tenantRequest.RequestStatus == TenantRequestStatusEnum.Scheduled || tenantRequest.RequestStatus == TenantRequestStatusEnum.Done || tenantRequest.RequestStatus == TenantRequestStatusEnum.Failed) { worker = _propertyRepository.GetWorkerByEmail(tenantRequest.WorkerEmail); if (worker == null) { throw new DomainEntityNotFoundException("worker_not_found", "Worker not found"); } } return(worker); }
public void UpdateTenantRequest(TenantRequest tTenantRequest) { var arrayFilters = new List <ArrayFilterDefinition> { new BsonDocumentArrayFilterDefinition <BsonDocument>(new BsonDocument("t.UnitNumber", tTenantRequest.Tenant.UnitNumber)), new BsonDocumentArrayFilterDefinition <BsonDocument>(new BsonDocument("r.Code", tTenantRequest.Code)) }; var updateOptions = new UpdateOptions { ArrayFilters = arrayFilters }; _properties.UpdateOne(x => x.Id == tTenantRequest.Tenant.PropertyCode, Builders <PropertyModel> .Update .Set("Tenants.$[t].Requests.$[r].RequestStatus", tTenantRequest.RequestStatus) .Set("Tenants.$[t].Requests.$[r].RequestChanges", _modelMapper.SerializeEvents(tTenantRequest.RequestChanges)) .Set("Tenants.$[t].Requests.$[r].ServiceWorkOrderCount", tTenantRequest.ServiceWorkOrderCount) , updateOptions ); }
public async Task <IActionResult> Put(int id, [FromBody] TenantRequest request) { try { await _tenantService.UpdateByCompanyId(id, request); return(NoContent()); } catch (ArgumentException ex) { return(BadRequest(ex.Message)); } catch (KeyNotFoundException ex) { return(NotFound(ex.Message)); } catch (DuplicateNameException ex) { return(Conflict(ex.Message)); } }
public async Task <Guid> Create(TenantRequest request) { if (request == null) { _logger.LogError($"[Create] Argument {nameof(request)} is null"); throw new ArgumentNullException(nameof(request)); } var tenants = await _tenantRepository.GetAsync(); if (tenants.Any(x => x.TenantName.ToLower() == request.Name.ToLower())) { _logger.LogError($"[Create] Duplicate parameter: {nameof(request.Name)}"); throw new DuplicateNameException(); } var tenant = request.Adapt <Tenant>(); tenant.CreatedOn = DateTime.UtcNow; return(await _tenantRepository.AddAsync(tenant)); }
public static PropertyTenantRequestViewModel BuildViewModel(this TenantRequest tenantRequest) { return(new PropertyTenantRequestViewModel() { RequestCode = tenantRequest.Code, RequestStatus = tenantRequest.RequestStatus.ToString().SplitPascalCase(), DateCreated = tenantRequest.DateCreated, UnitNumber = tenantRequest.TenantUnit, RequestTitle = tenantRequest.RequestTitle, RequestDescription = tenantRequest.RequestDescription, ShowCloseButton = tenantRequest.RequestStatus == TenantRequestStatusEnum.Declined || tenantRequest.RequestStatus == TenantRequestStatusEnum.Done, ShowScheduleRejectButtons = tenantRequest.RequestStatus == TenantRequestStatusEnum.Submitted, ShowScheduleButton = tenantRequest.RequestStatus == TenantRequestStatusEnum.Failed, ScheduledDate = DateTime.Now.Date, ShowReportButton = tenantRequest.RequestStatus == TenantRequestStatusEnum.Scheduled, PropertyCode = tenantRequest.Tenant.PropertyCode, History = tenantRequest.RequestChanges.BuildViewModel() }); }
public void AddTenantRequest(TenantRequest tenantRequest) { _requests.Add(tenantRequest.Id, tenantRequest); }