public async Task SendEmailToInitiatingStaffAsync(purch_requisitionnote prn) { EmailMessageObj em = new EmailMessageObj { ToAddresses = new List <EmailAddressObj>() }; var staffList = await _serverRequest.GetAllStaffAsync(); if (staffList.Count() > 0) { var intiatingStaff = staffList.FirstOrDefault(r => r.staffId == prn.StaffId); if (intiatingStaff != null) { //var path = $"#/main/lpos"; //var path2 = $"{_uRIs.SelfClient}/{path}"; em.Subject = "PRN APPROVED"; em.Content = $"The Request for {prn.Description} has been approved "; em.FromAddresses = new List <EmailAddressObj>(); var to = new EmailAddressObj { Address = intiatingStaff.Email, Name = intiatingStaff.firstName }; em.ToAddresses.Add(to); em.SendIt = true; em.SaveIt = false; em.Template = (int)EmailTemplate.Advert; await _serverRequest.SendMessageAsync(em); } } }
public IEnumerable <ApprovalDetailsObj> GetApprovalTrail(int targetId, string workflowToken) { var staffResponse = _serverRequest.GetAllStaffAsync().Result; var trail = _dataContext.cor_approvaldetail.Where(x => x.WorkflowToken.Contains(workflowToken) && x.TargetId == targetId); var data = trail.Select(x => new ApprovalDetailsObj { ApprovalDetailId = x.ApprovalDetailId, Comment = x.Comment, TargetId = x.TargetId, StaffId = x.StaffId, WorkflowToken = x.WorkflowToken, Date = x.Date, ArrivalDate = x.ArrivalDate, }).OrderByDescending(x => x.ApprovalDetailId).ToList(); foreach (var item in data) { item.FirstName = staffResponse.staff.FirstOrDefault(d => d.staffId == item.StaffId).firstName; item.LastName = staffResponse.staff.FirstOrDefault(d => d.staffId == item.StaffId).lastName; } return(data); }
public async Task <ApprovalDetailsRespObj> Handle(GetCurrentTargetApprovalDetailQuery request, CancellationToken cancellationToken) { var list = await _detail.GetApprovalDetailsAsync(request.TargetId, request.WorkflowToken); var supplierList = await _supRepo.GetAllSupplierAsync(); var staff = await _serverRequest.GetAllStaffAsync(); var response = new ApprovalDetailsRespObj { Status = new APIResponseStatus { IsSuccessful = true, Message = new APIResponseMessage() } }; var temp = list; var previousStaff = temp.GroupBy(d => d.StaffId).Select(d => d.First()).Where(d => d.StatusId == (int)ApprovalStatus.Approved && d.TargetId == request.TargetId && d.WorkflowToken == request.WorkflowToken).ToArray(); response.AprovalDetails = list.Select(x => new AprovalDetailsObj() { ApprovalDetailId = x.ApprovalDetailId, Comment = x.Comment, Date = x.Date, StaffId = x.StaffId, FirstName = staff.FirstOrDefault(d => d.staffId == x.StaffId)?.firstName, LastName = staff.FirstOrDefault(d => d.staffId == x.StaffId)?.lastName, StatusId = x.StatusId, StatusName = Convert.ToString((ApprovalStatus)x.StatusId), SupplierName = supplierList.FirstOrDefault(d => d.SupplierId == x.TargetId)?.Name, TargetId = x.TargetId, ArrivalDate = x.ArrivalDate, WorkflowToken = x.WorkflowToken, }).ToList(); response.PreviousStaff = previousStaff.Select(p => new PreviousStaff { StaffId = p.StaffId, Name = $"{staff.FirstOrDefault(d => d.staffId == p.StaffId)?.firstName} {staff.FirstOrDefault(d => d.staffId == p.StaffId)?.lastName}", }).ToList(); return(response); }
public async Task <LPOReport> Handle(LPOReportQuery request, CancellationToken cancellationToken) { var response = new LPOReport { Phases = new List <Phases>(), ServiceTerm = new ServiceTerm(), From = new From(), To = new To(), Status = new APIResponseStatus { Message = new APIResponseMessage(), IsSuccessful = true, }, }; try { var staff = await _serverRequest.GetAllStaffAsync(); var lpo = _dataContext.purch_plpo.FirstOrDefault(q => q.PLPOId == request.LPOId); var prn = _dataContext.purch_requisitionnote.FirstOrDefault(q => q.PurchaseReqNoteId == lpo.PurchaseReqNoteId); var serviceterms = _dataContext.cor_serviceterms.Where(q => q.ServiceTermsId == lpo.ServiceTerm).Select(w => new ServiceTerm { Content = w.Content, Header = w.Header }).ToList() ?? new List <ServiceTerm>(); var phases = _dataContext.cor_paymentterms.Where(w => w.LPOId == lpo.PLPOId && w.ProposedBy == (int)Proposer.STAFF).Select(w => new Phases { Amount = w.Amount, Tax = w.TaxPercent, Phase = w.Phase }).ToList(); var companies = await _serverRequest.GetAllCompanyStructureAsync(); var to = companies.companyStructures.Where(e => e.ParentCompanyID == 0).Select(r => new To { Address = r.Address1, Name = r.Name, Number = r.Telephone }).ToList(); var from = _dataContext.cor_supplier.Where(q => q.SupplierId == lpo.WinnerSupplierId).Select(s => new From { SupplierId = s.SupplierId, Address = s.Address, Name = s.Name, Number = s.SupplierNumber }).ToList(); response.AmountPayable = lpo.AmountPayable; response.GrossAmount = lpo.GrossAmount; response.LPONumber = lpo.LPONumber; response.Quantity = lpo.Quantity; response.RequestDate = lpo.RequestDate; response.TaxAmount = lpo.Tax; response.From = from.FirstOrDefault(); response.ServiceTerm = serviceterms.FirstOrDefault(); response.Phases = phases; response.Description = lpo.Description; response.Tax = lpo.Tax; response.To = to.FirstOrDefault(); return(response); } catch (Exception ex) { response.Status.IsSuccessful = false; response.Status.Message.FriendlyMessage = ex.Message; return(response); } }