public async Task <SendEmailRespObj> SendSpecificMessageAsync(EmailMessageObj email)
        {
            var response = new SendEmailRespObj {
                Status = new APIResponseStatus {
                    IsSuccessful = true, Message = new APIResponseMessage()
                }
            };

            try
            {
                var gosGatewayClient = _httpClientFactory.CreateClient("GOSDEFAULTGATEWAY");

                var jsonContent = JsonConvert.SerializeObject(email);
                var buffer      = Encoding.UTF8.GetBytes(jsonContent);
                var byteContent = new ByteArrayContent(buffer);
                byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                var result = await gosGatewayClient.PostAsync(ApiRoutes.IdentitySeverRequests.SEND_EMAIL_TO_SPECIFIC_OFFICERS, byteContent);

                var resultString = await result.Content.ReadAsStringAsync();

                response = JsonConvert.DeserializeObject <SendEmailRespObj>(resultString);
                return(response);
            }
            catch (Exception ex)
            {
                #region Log error
                var errorCode = ErrorID.Generate(4);
                _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
                throw ex;
                #endregion
            }
        }
        public async Task SendEmailToSuppliersWhenBidIsRejectedAsync(int Supplierid, string descsription)
        {
            EmailMessageObj em = new EmailMessageObj {
                ToAddresses = new List <EmailAddressObj>()
            };
            var supplier = await _dataContext.cor_supplier.FindAsync(Supplierid);

            if (supplier != null)
            {
                em.ToAddresses.Add(new EmailAddressObj {
                    Address = supplier.Email, Name = supplier.Name
                });
                var path = $"#/main/adverts";

                var path2 = $"{_uRIs.SelfClient}/{path}";
                em.Subject = "LPO Response";
                em.Content = $"Dear Supplier <br> You have successfully rejected the supply for this item  '{descsription}'" +
                             $"<br>Please click <a href='{path2}'> here </a> to see other available averts";
                em.FromAddresses = new List <EmailAddressObj>();
                em.SendIt        = true;
                em.SaveIt        = false;
                em.Template      = (int)EmailTemplate.Default;

                await _serverRequest.SendMessageAsync(em);
            }
        }
        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 async Task SendEmailToSupplierDetailingPaymentAsync(inv_invoice invoice, int phase)
        {
            EmailMessageObj em = new EmailMessageObj {
                ToAddresses = new List <EmailAddressObj>()
            };
            var supplier = await _dataContext.cor_supplier.FindAsync(invoice.SupplierId);

            if (supplier != null)
            {
                em.ToAddresses.Add(new EmailAddressObj {
                    Address = supplier.Email, Name = supplier.Name
                });
            }

            var path = $"#/main/lpos";

            var path2 = $"{_uRIs.SelfClient}/{path}";

            em.Subject = $"Phase {phase} Payment";
            em.Content = $"Dear Supplier <br> Invoice Number '{invoice.InvoiceNumber}' Phase '{phase}'" +
                         $" has successfully been paid for." +
                         $"<br>Please click <a href='{path2}'> here </a> to see details of Payment";
            em.FromAddresses = new List <EmailAddressObj>();
            em.SendIt        = true;
            em.SaveIt        = false;
            em.Template      = (int)EmailTemplate.Default;

            await _serverRequest.SendMessageAsync(em);
        }
        public async Task SendEmailToSuppliersSelectedAsync(int winnerSupplierid, string descsription, int id)
        {
            EmailMessageObj em = new EmailMessageObj {
                ToAddresses = new List <EmailAddressObj>()
            };
            var supplier = await _dataContext.cor_supplier.FindAsync(winnerSupplierid);

            if (supplier != null)
            {
                em.ToAddresses.Add(new EmailAddressObj {
                    Address = supplier.Email, Name = supplier.Name
                });
            }

            var path = $"#/main/lpos";

            var path2 = $"{_uRIs.SelfClient}/{path}";

            em.Subject = "Bid Selected";
            em.Content = $"Dear {supplier.Name} <br> Congratulations you have been successfully selected for the supplier of '{descsription}'" +
                         $"<br><b>Note :</b> Before the final approval of the Local purchase order (LPO), you can be able to reject the supply of {descsription}. <br> Please click  <a href='{path2}'> here</a> to see the approved proposal breakdown for the supplier of {descsription}";
            em.FromAddresses = new List <EmailAddressObj>();
            em.SendIt        = true;
            em.SaveIt        = false;
            em.Template      = (int)EmailTemplate.Advert;

            await _serverRequest.SendMessageAsync(em);
        }
Ejemplo n.º 6
0
        private async Task SendMailToNewSuppliersAsync(ApplicationUser user)
        {
            var em = new EmailMessageObj {
                FromAddresses = new List <EmailAddressObj>(), ToAddresses = new List <EmailAddressObj>()
            };
            var ema = new EmailAddressObj
            {
                Address = user.Email,
                Name    = user.UserName
            };
            var path2 = $"{_uRIs.SelfClient}/#/auth/login";

            em.ToAddresses.Add(ema);
            em.Subject = "Supplier Account Created";
            em.Content = $"<p style='float:left'> Dear {user.FullName} <br> " +
                         $"Congratulations, your account has been successfully created <br> " +
                         $"Below is your profile login details<br>" +
                         $"<b>Username</b>: {user.Email} <br>" +
                         $"<b>Password</b>: Password@1 <br>" +
                         $"Please click <a href='{path2}'> here </a>  to access your profile and to complete registration</p>";

            em.SendIt   = true;
            em.SaveIt   = false;
            em.Template = (int)EmailTemplate.LoginDetails;

            await _serverRequest.SendMessageAsync(em);
        }
Ejemplo n.º 7
0
        private async Task SendMailToUpdatedSuppliersAsync(ApplicationUser user)
        {
            var em = new EmailMessageObj();

            em.ToAddresses.Add(new EmailAddressObj {
                Address = user.Email
            });
            em.Subject = "Profile Login Details Updated";
            em.Content = $"Dear {user.FullName} <p>Your supplier account was successfully created </p> <br> Below is your account details" +
                         $"by stating your terms which may be negotiable and best for this product and service";
            em.SendIt = true;
            await _serverRequest.SendMessageAsync(em);
        }
Ejemplo n.º 8
0
        private async Task SendMail(string email, string name)
        {
            var sm = new EmailMessageObj();

            sm.Subject = $" Supplier account details";
            sm.Content = $"Hello {name} <br/>" +
                         $"Your supplier account has sussefully being approved. <br/>" +
                         $"Below is your account login details" +
                         $"<b>Username : {email} <br/>" +
                         $"<b>Password : Password@1 <br/>" +
                         $"Please be sure to change your password on first login";;
            sm.ToAddresses.Add(new EmailAddressObj {
                Address = email, Name = name
            });
            await _serverRequest.SendMessageAsync(sm);
        }
        public async Task SendEmailToSuppliersAsync(EmailMessageObj em, string description)
        {
            var path = $"#/main/adverts";

            var path2 = $"{_uRIs.SelfClient}/{path}";

            em.Subject = "Selected to supply";
            em.Content = $"Dear Supplier <br> You have been selected to bid for  {description} from your advert page <br>" +
                         $"Kindly provide a proposal breakdown for the supply of {description} <br>" +
                         $"You can also upload your proposal terms" +
                         $"<br>Please click <a href='{path2}'> here </a> to see adverts";
            em.FromAddresses = new List <EmailAddressObj>();
            em.SendIt        = true;
            em.SaveIt        = false;
            em.Template      = (int)EmailTemplate.Advert;

            await _serverRequest.SendMessageAsync(em);
        }
Ejemplo n.º 10
0
            public async Task <EmailRespObj> Handle(GetSingleEmailDetailsComandQuery request, CancellationToken cancellationToken)
            {
                var response = new EmailRespObj {
                    Emails = new List <EmailMessageObj>(), Status = new APIResponseStatus {
                        IsSuccessful = false, Message = new APIResponseMessage()
                    }
                };

                try
                {
                    var res = await _email.GetSingleEmailAsync(request.EmailId);

                    if (res != null)
                    {
                        if (res.EmailStatus == (int)EmailStatus.Received)
                        {
                            res.EmailStatus = (int)EmailStatus.Read;
                            await _email.SaveUpdateEmailAsync(res);
                        }

                        var email = new EmailMessageObj
                        {
                            Content        = res.Content,
                            DateSent       = res.DateSent,
                            EmailMessageId = res.EmailMessageId,
                            EmailStatus    = res.EmailStatus,
                            StatusName     = Convert.ToString((EmailStatus)res.EmailStatus),
                            SentBy         = res.SentBy,
                            ReceivedBy     = res.ReceivedBy,
                            Subject        = res.Subject,
                        } ?? new EmailMessageObj();
                        response.Status.IsSuccessful = true;
                        response.Emails.Add(email);
                        return(response);
                    }
                    return(response);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            public async Task SendEmailToOfficerForPaymentAsync(cor_paymentterms phase, purch_plpo lpo)
            {
                var userid = _accessor.HttpContext.User?.FindFirst(q => q.Type == "userId")?.Value;
                var user   = await _userManager.FindByIdAsync(userid);

                if (user != null)
                {
                    EmailMessageObj em = new EmailMessageObj {
                        ToAddresses = new List <EmailAddressObj>(), FromAddresses = new List <EmailAddressObj>()
                    };

                    var supplier = _dataContext.cor_supplier.FirstOrDefault(q => q.Email == user.Email);
                    var path     = $"#/purchases-and-supplier/lpo?id={phase.LPOId}";

                    var path2 = $"{_uRIs.MainClient}/{path}";


                    em.Subject = $"Payment Request";
                    em.Content = $"Supplier with supplier number {supplier.SupplierNumber} <br> is requesting for payment for " +
                                 $"the supply of {lpo.Description} <br> on  Phase '{phase.Phase}'" +
                                 $" with project status of '{ Convert.ToString((JobProgressStatus)phase.Status)} '" +
                                 $"<br> Please click <a href='{path2}'> here </a> to see details of Payment";

                    var frm = new EmailAddressObj
                    {
                        Address = supplier.Email,
                        Name    = supplier.Name,
                    };
                    em.FromAddresses.Add(frm);
                    em.ActivitIds = new List <int>();
                    em.ActivitIds.Add(14);
                    em.SendIt   = true;
                    em.SaveIt   = false;
                    em.Template = (int)EmailTemplate.Advert;

                    await _serverRequest.SendSpecificMessageAsync(em);
                }
            }
        public async Task <StaffApprovalRegRespObj> Handle(PRNStaffApprovalCommand request, CancellationToken cancellationToken)
        {
            try
            {
                if (request.ApprovalStatus == (int)ApprovalStatus.Revert && request.ReferredStaffId < 1)
                {
                    return(new StaffApprovalRegRespObj
                    {
                        Status = new APIResponseStatus {
                            IsSuccessful = false, Message = new APIResponseMessage {
                                FriendlyMessage = "Please select staff to revert to"
                            }
                        }
                    });
                }
                var allSuppliers = await _dataContext.cor_supplier.ToListAsync();

                var currentUserId = _accessor.HttpContext.User?.FindFirst(x => x.Type == "userId").Value;
                var user          = await _serverRequest.UserDataAsync();

                var prn = await _repo.GetPurchaseRequisitionNoteAsync(request.TargetId);

                var detail = BuildApprovalDetailObject(request, prn, user.StaffId);

                var req = new IndentityServerApprovalCommand
                {
                    ApprovalComment = request.ApprovalComment,
                    ApprovalStatus  = request.ApprovalStatus,
                    TargetId        = request.TargetId,
                    WorkflowToken   = prn.WorkflowToken,
                    ReferredStaffId = request.ReferredStaffId
                };

                using (var _trans = await _dataContext.Database.BeginTransactionAsync())
                {
                    try
                    {
                        var result = await _serverRequest.StaffApprovalRequestAsync(req);

                        if (!result.IsSuccessStatusCode)
                        {
                            var stringData2 = await result.Content.ReadAsStringAsync();

                            response = JsonConvert.DeserializeObject <StaffApprovalRegRespObj>(stringData2);
                            return(new StaffApprovalRegRespObj
                            {
                                Status = response.Status
                            });
                        }

                        var stringData = await result.Content.ReadAsStringAsync();

                        response = JsonConvert.DeserializeObject <StaffApprovalRegRespObj>(stringData);

                        if (!response.Status.IsSuccessful)
                        {
                            return(new StaffApprovalRegRespObj
                            {
                                Status = response.Status
                            });
                        }
                        if (response.ResponseId == (int)ApprovalStatus.Processing)
                        {
                            await _detailService.AddUpdateApprovalDetailsAsync(detail);

                            prn.ApprovalStatusId = (int)ApprovalStatus.Processing;
                            await _repo.AddUpdatePurchaseRequisitionNoteAsync(prn);

                            await _trans.CommitAsync();

                            return(new StaffApprovalRegRespObj
                            {
                                ResponseId = (int)ApprovalStatus.Processing,
                                Status = new APIResponseStatus {
                                    IsSuccessful = true, Message = response.Status.Message
                                }
                            });
                        }
                        if (response.ResponseId == (int)ApprovalStatus.Revert)
                        {
                            await _detailService.AddUpdateApprovalDetailsAsync(detail);

                            prn.ApprovalStatusId = (int)ApprovalStatus.Revert;
                            await _repo.AddUpdatePurchaseRequisitionNoteAsync(prn);

                            await _trans.CommitAsync();

                            return(new StaffApprovalRegRespObj
                            {
                                ResponseId = (int)ApprovalStatus.Revert,
                                Status = new APIResponseStatus {
                                    IsSuccessful = true, Message = response.Status.Message
                                }
                            });
                        }
                        if (response.ResponseId == (int)ApprovalStatus.Approved)
                        {
                            await _detailService.AddUpdateApprovalDetailsAsync(detail);

                            prn.ApprovalStatusId = (int)ApprovalStatus.Approved;
                            var prnDetails = await _repo.GetPrnDetailsByPrnId(prn.PurchaseReqNoteId);

                            EmailMessageObj email = new EmailMessageObj {
                                ToAddresses = new List <EmailAddressObj>()
                            };

                            foreach (var item in prnDetails)
                            {
                                item.LPONumber = _repo.LpoNubmer(prn.PurchaseReqNoteId + item.PRNDetailsId);

                                if (await _repo.AddUpdatePrnDetailsAsync(item))
                                {
                                    var lpoObject = _repo.BuildLPODomianObject(item, prn.DeliveryLocation, prn.ExpectedDeliveryDate ?? DateTime.Today);
                                    item.PurchaseReqNoteId = prn.PurchaseReqNoteId;
                                    if (await _repo.AddUpdateLPOAsync(lpoObject))
                                    {
                                        var SuggestedSupplierList = lpoObject.SupplierIds.Split(',').Select(int.Parse);
                                        foreach (var supplierId in SuggestedSupplierList)
                                        {
                                            var supplier = await _supRepo.GetSupplierAsync(supplierId);

                                            if (supplier != null)
                                            {
                                                var bidAndTenderObject = _repo.BuildBidAndTenderDomianObject(supplier, lpoObject, prn.DepartmentId, item);
                                                bidAndTenderObject.CompanyId         = prn.CompanyId;
                                                bidAndTenderObject.PurchaseReqNoteId = prn.PurchaseReqNoteId;
                                                if (await _repo.AddUpdateBidAndTender(bidAndTenderObject))
                                                {
                                                    email.ToAddresses.Add(new EmailAddressObj {
                                                        Address = supplier.Email, Name = supplier.Name
                                                    });
                                                }
                                            }
                                        }
                                        var otherSupplierbid = _repo.BuildBidAndTenderDomianObjectForNonSelectedSuppliers(lpoObject, prn.DepartmentId, item);
                                        await _repo.AddUpdateBidAndTender(otherSupplierbid);
                                    }
                                }
                            }
                            email.ToAddresses.Distinct();
                            await _repo.SendEmailToSuppliersAsync(email, prn.Description);

                            await _repo.AddUpdatePurchaseRequisitionNoteAsync(prn);

                            await _repo.SendEmailToInitiatingStaffAsync(prn);

                            await _trans.CommitAsync();

                            return(new StaffApprovalRegRespObj
                            {
                                ResponseId = (int)ApprovalStatus.Approved,
                                Status = new APIResponseStatus {
                                    IsSuccessful = true, Message = new APIResponseMessage {
                                        FriendlyMessage = "Final Approval </br> Successfully created Supplier Bids"
                                    }
                                }
                            });
                        }
                        if (response.ResponseId == (int)ApprovalStatus.Disapproved)
                        {
                            await _detailService.AddUpdateApprovalDetailsAsync(detail);

                            prn.ApprovalStatusId = (int)ApprovalStatus.Disapproved;
                            await _repo.AddUpdatePurchaseRequisitionNoteAsync(prn);

                            await _trans.CommitAsync();

                            return(new StaffApprovalRegRespObj
                            {
                                ResponseId = (int)ApprovalStatus.Disapproved,
                                Status = new APIResponseStatus {
                                    IsSuccessful = true, Message = response.Status.Message
                                }
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        await _trans.RollbackAsync();

                        throw ex;
                    }
                    finally { await _trans.DisposeAsync(); }
                }

                return(new StaffApprovalRegRespObj
                {
                    ResponseId = detail.ApprovalDetailId,
                    Status = response.Status
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <RequisitionNoteRegRespObj> Handle(AddUpdateRequisitionNoteCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var apiResponse = new RequisitionNoteRegRespObj {
                    Status = new APIResponseStatus {
                        IsSuccessful = false, Message = new APIResponseMessage()
                    }
                };
                var user = await _serverRequest.UserDataAsync();

                if (user == null)
                {
                    return(new RequisitionNoteRegRespObj
                    {
                        Status = new APIResponseStatus {
                            IsSuccessful = false, Message = new APIResponseMessage {
                                FriendlyMessage = " Unable To Process This User"
                            }
                        }
                    });
                }

                List <purch_prndetails> prnDetails = new List <purch_prndetails>();
                using (var _trans = await _dataContext.Database.BeginTransactionAsync())
                {
                    try
                    {
                        var prn = _repo.BuildPurchRequisionNoteObject(request, user.StaffId, user.CompanyId);
                        await _repo.AddUpdatePurchaseRequisitionNoteAsync(prn);

                        if (request.PRNDetails.Count() > 0)
                        {
                            prnDetails = _repo.BuildListOfPrnDetails(request.PRNDetails, prn.CompanyId);
                        }
                        var targetList = new List <int>();
                        targetList.Add(prn.PurchaseReqNoteId);
                        GoForApprovalRequest wfRequest = new GoForApprovalRequest
                        {
                            Comment                = "Purchase PRN",
                            OperationId            = (int)OperationsEnum.PurchasePRNApproval,
                            TargetId               = targetList,
                            ApprovalStatus         = (int)ApprovalStatus.Pending,
                            DeferredExecution      = true,
                            StaffId                = user.StaffId,
                            CompanyId              = user.CompanyId,
                            EmailNotification      = true,
                            ExternalInitialization = false,
                            StatusId               = (int)ApprovalStatus.Processing,
                        };
                        var result = await _serverRequest.GotForApprovalAsync(wfRequest);

                        if (!result.IsSuccessStatusCode)
                        {
                            apiResponse.Status.Message.FriendlyMessage = $"{result.ReasonPhrase} {result.StatusCode}";
                            return(apiResponse);
                        }
                        var stringData = await result.Content.ReadAsStringAsync();

                        var res = JsonConvert.DeserializeObject <GoForApprovalRespObj>(stringData);
                        if (res.ApprovalProcessStarted)
                        {
                            prn.ApprovalStatusId = (int)ApprovalStatus.Processing;
                            prn.WorkflowToken    = res.Status.CustomToken;

                            await _repo.AddUpdatePurchaseRequisitionNoteAsync(prn);

                            foreach (var item in prnDetails)
                            {
                                item.PurchaseReqNoteId = prn.PurchaseReqNoteId;
                                await _repo.AddUpdatePrnDetailsAsync(item);
                            }
                            await _trans.CommitAsync();

                            apiResponse.PurchaseReqNoteId   = prn.PurchaseReqNoteId;
                            apiResponse.Status.IsSuccessful = res.Status.IsSuccessful;
                            apiResponse.Status.Message      = res.Status.Message;
                            return(apiResponse);
                        }

                        if (res.EnableWorkflow || !res.HasWorkflowAccess)
                        {
                            await _trans.CommitAsync();

                            apiResponse.PurchaseReqNoteId              = prn.PurchaseReqNoteId;
                            apiResponse.Status.IsSuccessful            = true;
                            apiResponse.Status.Message.FriendlyMessage = "Successful";
                            return(apiResponse);
                        }
                        if (!res.EnableWorkflow)
                        {
                            prn.ApprovalStatusId = (int)ApprovalStatus.Approved;
                            EmailMessageObj email = new EmailMessageObj {
                                ToAddresses = new List <EmailAddressObj>()
                            };
                            var lponum = 0;
                            foreach (var item in prnDetails)
                            {
                                if (await _repo.AddUpdatePrnDetailsAsync(item))
                                {
                                    item.LPONumber         = _repo.LpoNubmer(prn.PurchaseReqNoteId + item.PRNDetailsId);
                                    item.PurchaseReqNoteId = prn.PurchaseReqNoteId;
                                    await _repo.AddUpdatePrnDetailsAsync(item);

                                    var lpoObject = _repo.BuildLPODomianObject(item, prn.DeliveryLocation, prn.ExpectedDeliveryDate ?? DateTime.Today);
                                    if (await _repo.AddUpdateLPOAsync(lpoObject))
                                    {
                                        var SuggestedSupplierList = lpoObject.SupplierIds.Split(',').Select(int.Parse);
                                        foreach (var supplierId in SuggestedSupplierList)
                                        {
                                            var supplier = await _suprepo.GetSupplierAsync(supplierId);

                                            if (supplier != null)
                                            {
                                                var bidAndTenderObject = _repo.BuildBidAndTenderDomianObject(supplier, lpoObject, prn.DepartmentId, item);
                                                bidAndTenderObject.CompanyId         = prn.CompanyId;
                                                bidAndTenderObject.PurchaseReqNoteId = prn.PurchaseReqNoteId;
                                                if (await _repo.AddUpdateBidAndTender(bidAndTenderObject))
                                                {
                                                    email.ToAddresses.Add(new EmailAddressObj {
                                                        Address = supplier.Email, Name = supplier.Name
                                                    });
                                                }
                                            }
                                        }
                                        var otherSupplierbid = _repo.BuildBidAndTenderDomianObjectForNonSelectedSuppliers(lpoObject, prn.DepartmentId, item);
                                        otherSupplierbid.PurchaseReqNoteId = prn.PurchaseReqNoteId;
                                        otherSupplierbid.CompanyId         = prn.CompanyId;
                                        await _repo.AddUpdateBidAndTender(otherSupplierbid);
                                    }
                                }
                            }
                            email.ToAddresses.Distinct();
                            await _repo.SendEmailToSuppliersAsync(email, prn.Description);

                            await _repo.AddUpdatePurchaseRequisitionNoteAsync(prn);

                            await _trans.CommitAsync();

                            apiResponse.Status.IsSuccessful            = true;
                            apiResponse.Status.Message.FriendlyMessage = "Successful";
                            return(apiResponse);
                        }
                    }
                    catch (SqlException ex)
                    {
                        await _trans.RollbackAsync();

                        var errorCode = ErrorID.Generate(4);
                        _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
                        throw ex;
                    }
                    finally { await _trans.DisposeAsync(); }
                }
                return(new RequisitionNoteRegRespObj
                {
                    Status = new APIResponseStatus
                    {
                        IsSuccessful = true,
                        Message = new APIResponseMessage
                        {
                            FriendlyMessage = "Success"
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                #region Log error to file
                var errorCode = ErrorID.Generate(4);
                _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
                return(new RequisitionNoteRegRespObj
                {
                    Status = new APIResponseStatus
                    {
                        IsSuccessful = false,
                        Message = new APIResponseMessage
                        {
                            FriendlyMessage = "Error occured!! Unable to process item",
                            MessageId = errorCode,
                            TechnicalMessage = $"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}"
                        }
                    }
                });

                #endregion
            }
        }