Exemple #1
0
        public async Task <CommonResponse> SetQuoteDetails([FromBody] QuoteSetReq request)
        {
            var response = new CommonResponse();

            try
            {
                if (request != null)
                {
                    string result = await _commercialsRepository.SetQuoteDetails(request);

                    response.QRFID = result;
                    response.ResponseStatus.Status = "Success";
                }
                else
                {
                    response.ResponseStatus.Status       = "Failure";
                    response.ResponseStatus.ErrorMessage = "Details can not be blank.";
                }
                if (!string.IsNullOrEmpty(response.ResponseStatus.Status) && response.ResponseStatus.Status == "Success" && !string.IsNullOrEmpty(request.QRFID) && !string.IsNullOrEmpty(request.VoyagerUserID))
                {
                    Task.Run(() => _mSDynamicsRepository.CreateUpdateOpportnity(request.QRFID, request.VoyagerUserID).Result);
                }
            }
            catch (Exception ex)
            {
                response.ResponseStatus.Status       = "Failure";
                response.ResponseStatus.ErrorMessage = "An Error Occurs " + ex.Message;
            }
            return(response);
        }
Exemple #2
0
        public CommonResponse UpdateQuoteDetails(IConfiguration _configuration, string token, string QRFID, string remarks, string enquiryPipeline, bool IsApproveQuote, string Officer, IRequestCookieCollection objCookies, List <ProductAttributeDetails> SessionInfo)
        {
            QuoteSetReq objQuoteRequest = new QuoteSetReq();
            string      emailId         = "";

            objCookies.TryGetValue("EmailId", out emailId);
            emailId = string.IsNullOrEmpty(emailId) ? SessionInfo.Where(a => a.AttributeId == "EmailId").Select(b => b.Value).FirstOrDefault() : emailId;
            string PlacerUser = "";

            objCookies.TryGetValue("UserName", out PlacerUser);
            PlacerUser = string.IsNullOrEmpty(PlacerUser) ? SessionInfo.Where(a => a.AttributeId == "UserName").Select(b => b.Value).FirstOrDefault() : PlacerUser;
            string userId = "";

            objCookies.TryGetValue("VoyagerUser_Id", out userId);
            userId = string.IsNullOrEmpty(userId) ? SessionInfo.Where(a => a.AttributeId == "VoyagerUser_Id").Select(b => b.Value).FirstOrDefault() : userId;
            objQuoteRequest.QRFID           = QRFID;
            objQuoteRequest.Remarks         = remarks;
            objQuoteRequest.PlacerEmail     = emailId;
            objQuoteRequest.PlacerUser      = PlacerUser;
            objQuoteRequest.EnquiryPipeline = enquiryPipeline;
            objQuoteRequest.IsApproveQuote  = IsApproveQuote;
            objQuoteRequest.PlacerUserId    = userId;
            objQuoteRequest.CostingOfficer  = Officer;
            objQuoteRequest.VoyagerUserID   = objCookies["VoyagerUser_Id"] ?? SessionInfo.Where(x => x.AttributeId == "VoyagerUser_Id").Select(b => b.Value).FirstOrDefault();

            CommonResponse objQuoteResponse = coProviders.UpdateQuoteDetails(objQuoteRequest, token).Result;

            return(objQuoteResponse);
        }
Exemple #3
0
        public async Task <CommonResponse> UpdateQuoteDetails(QuoteSetReq objQuoteRequest, string ticket)
        {
            CommonResponse objCommonResponse = new CommonResponse();

            objCommonResponse = await serviceProxy.PostData(_configuration.GetValue <string>("ServiceCommercials:SetQuoteDetails"), objQuoteRequest, typeof(CommonResponse), ticket);

            return(objCommonResponse);
        }
        public async Task <QuoteSetRes> UpdateQuoteDetails(QuoteSetReq objQuoteSetReq, string ticket)
        {
            QuoteSetRes objQuoteSetRes = new QuoteSetRes();

            objQuoteSetRes = await serviceProxy.PostData(_configuration.GetValue <string>("ServiceQRFSummary:SubmitQuote"), objQuoteSetReq, typeof(QuoteSetRes), ticket);

            return(objQuoteSetRes);
        }
        public async Task <QuoteSetRes> SubmitQuote([FromBody] QuoteSetReq request)
        {
            var response = new QuoteSetRes();

            try
            {
                if (request != null)
                {
                    response = await _qrfSummarRepository.SubmitQuote(request);

                    if (response == null)
                    {
                        response = new QuoteSetRes()
                        {
                            ResponseStatus = new ResponseStatus()
                            {
                                Status = "Error", ErrorMessage = "Error while Submitting Quote"
                            }
                        }
                    }
                    ;
                }
                else
                {
                    response.ResponseStatus.Status       = "Failure";
                    response.ResponseStatus.ErrorMessage = "Details can not be blank.";
                }
                if (!string.IsNullOrEmpty(response.ResponseStatus.Status) && response.ResponseStatus.Status == "Success" && !string.IsNullOrEmpty(request.QRFID) && !string.IsNullOrEmpty(request.VoyagerUserID))
                {
                    Task.Run(() => _mSDynamicsRepository.CreateUpdateOpportnity(request.QRFID, request.VoyagerUserID).Result);
                }
            }
            catch (Exception ex)
            {
                response.ResponseStatus.Status       = "Failure";
                response.ResponseStatus.ErrorMessage = "An Error Occurs " + ex.Message;
            }
            return(response);
        }
        public async Task <string> SetQuoteDetails(QuoteSetReq request)
        {
            try
            {
                if (!string.IsNullOrEmpty(request.QRFID))
                {
                    if (!string.IsNullOrEmpty(request.EnquiryPipeline))
                    {
                        bool flag = false;
                        if (request.EnquiryPipeline.ToLower() == "costing pipeline")
                        {
                            if (request.IsApproveQuote)
                            {
                                await _MongoContext.mQuote.FindOneAndUpdateAsync(
                                    Builders <mQuote> .Filter.Eq("QRFID", request.QRFID),
                                    Builders <mQuote> .Update.
                                    Set("CurrentPipeline", "Costing Approval Pipeline").
                                    Set("CurrentPipelineStep", "Costing").
                                    Set("Remarks", request.Remarks).
                                    Set("CurrentPipelineSubStep", "Itinerary").
                                    Set("QuoteResult", "Success").
                                    Set("Status", "NewCostingApprovalPipeline").
                                    Set("EditUser", request.PlacerEmail).
                                    Set("EditDate", DateTime.Now)
                                    );

                                await _MongoContext.mQRFPrice.UpdateManyAsync(
                                    Builders <mQRFPrice> .Filter.Eq("QRFID", request.QRFID),
                                    Builders <mQRFPrice> .Update.
                                    Set("ProductAccountant", request.CostingOfficer).
                                    Set("EditUser", request.PlacerEmail).
                                    Set("EditDate", DateTime.Now)
                                    );

                                #region Add Followup
                                request.PlacerEmail    = request.PlacerEmail.ToLower().Trim();
                                request.CostingOfficer = request.CostingOfficer.Trim().ToLower();
                                var CompanyList      = _MongoContext.mCompanies.AsQueryable();
                                var FromUserContacts = CompanyList.Where(x => x.ContactDetails != null && x.ContactDetails.Count > 0 && x.ContactDetails.Any(a => a.MAIL.ToLower() == request.PlacerEmail)).FirstOrDefault()?.ContactDetails;
                                var FromUser         = FromUserContacts?.Where(a => a.MAIL.ToLower() == request.PlacerEmail).FirstOrDefault();
                                var ToUserContacts   = CompanyList.Where(x => x.ContactDetails != null && x.ContactDetails.Count > 0 && x.ContactDetails.Any(a => a.MAIL.ToLower() == request.CostingOfficer)).FirstOrDefault()?.ContactDetails;
                                var ToUser           = ToUserContacts?.Where(a => a.MAIL.ToLower() == request.CostingOfficer).FirstOrDefault();

                                FollowUpSetRes response        = new FollowUpSetRes();
                                FollowUpSetReq followUprequest = new FollowUpSetReq();
                                followUprequest.QRFID = request.QRFID;

                                FollowUpTask task = new FollowUpTask();
                                task.Task             = "Costing Approval Requested";
                                task.FollowUpType     = "Internal";
                                task.FollowUpDateTime = DateTime.Now;

                                task.FromEmail = request.PlacerEmail;
                                if (FromUser != null)
                                {
                                    task.FromName       = FromUser.CommonTitle + " " + FromUser.FIRSTNAME + " " + FromUser.LastNAME;
                                    task.FromContact_Id = FromUser.Contact_Id;
                                }

                                task.ToEmail = request.CostingOfficer;
                                if (ToUser != null)
                                {
                                    task.ToName       = ToUser.CommonTitle + " " + ToUser.FIRSTNAME + " " + ToUser.LastNAME;
                                    task.ToContact_Id = ToUser.Contact_Id;
                                }

                                task.Status = "Pending for Approval";
                                task.Notes  = "Costing Approval Requested";

                                var FollowUpTaskList = new List <FollowUpTask>();
                                FollowUpTaskList.Add(task);

                                followUprequest.FollowUp.Add(new FollowUp
                                {
                                    FollowUp_Id  = Guid.NewGuid().ToString(),
                                    FollowUpTask = FollowUpTaskList,
                                    CreateUser   = request.PlacerEmail,
                                    CreateDate   = DateTime.Now
                                });
                                await _quoteRepository.SetFollowUpForQRF(followUprequest);

                                #endregion
                            }
                            else
                            {
                                #region Add Followup
                                request.PlacerEmail = request.PlacerEmail.ToLower().Trim();
                                var SalesOfficer     = _MongoContext.mQRFPrice.AsQueryable().Where(a => a.QRFID == request.QRFID && a.IsCurrentVersion == true).FirstOrDefault()?.SalesOfficer?.ToLower().Trim();
                                var CompanyList      = _MongoContext.mCompanies.AsQueryable();
                                var FromUserContacts = CompanyList.Where(x => x.ContactDetails != null && x.ContactDetails.Count > 0 && x.ContactDetails.Any(a => a.MAIL.ToLower() == request.PlacerEmail)).FirstOrDefault()?.ContactDetails;
                                var FromUser         = FromUserContacts?.Where(a => a.MAIL.ToLower() == request.PlacerEmail).FirstOrDefault();
                                var ToUserContacts   = CompanyList.Where(x => x.ContactDetails != null && x.ContactDetails.Count > 0 && x.ContactDetails.Any(a => a.MAIL.ToLower() == SalesOfficer)).FirstOrDefault()?.ContactDetails;
                                var ToUser           = ToUserContacts?.Where(a => a.MAIL.ToLower() == SalesOfficer).FirstOrDefault();

                                FollowUpSetRes response        = new FollowUpSetRes();
                                FollowUpSetReq followUprequest = new FollowUpSetReq();
                                followUprequest.QRFID = request.QRFID;

                                FollowUpTask task = new FollowUpTask();
                                task.Task             = "QRF Change Suggested";
                                task.FollowUpType     = "Internal";
                                task.FollowUpDateTime = DateTime.Now;

                                task.FromEmail = request.PlacerEmail;
                                if (FromUser != null)
                                {
                                    task.FromName       = FromUser.CommonTitle + " " + FromUser.FIRSTNAME + " " + FromUser.LastNAME;
                                    task.FromContact_Id = FromUser.Contact_Id;
                                }

                                task.ToEmail = SalesOfficer;
                                if (ToUser != null)
                                {
                                    task.ToName       = ToUser.CommonTitle + " " + ToUser.FIRSTNAME + " " + ToUser.LastNAME;
                                    task.ToContact_Id = ToUser.Contact_Id;
                                }

                                task.Status = "Draft";
                                task.Notes  = "QRF Change Suggested";

                                var FollowUpTaskList = new List <FollowUpTask>();
                                FollowUpTaskList.Add(task);

                                followUprequest.FollowUp.Add(new FollowUp
                                {
                                    FollowUp_Id  = Guid.NewGuid().ToString(),
                                    FollowUpTask = FollowUpTaskList,
                                    CreateUser   = request.PlacerEmail,
                                    CreateDate   = DateTime.Now
                                });
                                await _quoteRepository.SetFollowUpForQRF(followUprequest);

                                #endregion

                                await _MongoContext.mQuote.FindOneAndUpdateAsync(
                                    Builders <mQuote> .Filter.Eq("QRFID", request.QRFID),
                                    Builders <mQuote> .Update.
                                    Set("CurrentPipeline", "Quote Pipeline").
                                    Set("CurrentPipelineStep", "Quote").
                                    Set("Remarks", request.Remarks).
                                    Set("CurrentPipelineSubStep", "AgentInformation").
                                    Set("QuoteResult", "Success").
                                    Set("Status", "NewQuote").
                                    Set("EditUser", request.PlacerEmail).
                                    Set("EditDate", DateTime.Now)
                                    );

                                flag = await SetDataFromCostingToSales(request.QRFID, request.PlacerEmail, request.PlacerUser);
                            }
                        }
                        else if (request.EnquiryPipeline.ToLower() == "amendment pipeline")
                        {
                            await _MongoContext.mQuote.FindOneAndUpdateAsync(
                                Builders <mQuote> .Filter.Eq("QRFID", request.QRFID),
                                Builders <mQuote> .Update.
                                Set("CurrentPipeline", "Costing Approval Pipeline").
                                Set("CurrentPipelineStep", "Costing").
                                Set("Remarks", request.Remarks).
                                Set("CurrentPipelineSubStep", "Itinerary").
                                Set("QuoteResult", "Success").
                                Set("Status", "NewCostingApprovalPipeline").
                                Set("EditUser", request.PlacerEmail).
                                Set("EditDate", DateTime.Now)
                                );

                            await _MongoContext.mQRFPrice.UpdateManyAsync(
                                Builders <mQRFPrice> .Filter.Eq("QRFID", request.QRFID),
                                Builders <mQRFPrice> .Update.
                                Set("ProductAccountant", request.CostingOfficer).
                                Set("EditUser", request.PlacerEmail).
                                Set("EditDate", DateTime.Now)
                                );
                        }
                        else if (request.EnquiryPipeline.ToLower() == "costing approval pipeline")
                        {
                            if (request.IsApproveQuote)
                            {
                                await _MongoContext.mQuote.FindOneAndUpdateAsync(
                                    Builders <mQuote> .Filter.Eq("QRFID", request.QRFID),
                                    Builders <mQuote> .Update.
                                    Set("CurrentPipeline", "Agent Approval Pipeline").
                                    Set("CurrentPipelineStep", "").
                                    Set("Remarks", request.Remarks).
                                    Set("CurrentPipelineSubStep", "").
                                    Set("QuoteResult", "Success").
                                    Set("Status", "NewAgentApprovalPipeline").
                                    Set("EditUser", request.PlacerEmail).
                                    Set("EditDate", DateTime.Now)
                                    );

                                #region Add Followup
                                request.PlacerEmail = request.PlacerEmail.ToLower().Trim();
                                var SalesOfficer     = _MongoContext.mQRFPrice.AsQueryable().Where(a => a.QRFID == request.QRFID && a.IsCurrentVersion == true).FirstOrDefault()?.SalesOfficer?.ToLower().Trim();
                                var CompanyList      = _MongoContext.mCompanies.AsQueryable();
                                var FromUserContacts = CompanyList.Where(x => x.ContactDetails != null && x.ContactDetails.Count > 0 && x.ContactDetails.Any(a => a.MAIL.ToLower() == request.PlacerEmail)).FirstOrDefault()?.ContactDetails;
                                var FromUser         = FromUserContacts?.Where(a => a.MAIL.ToLower() == request.PlacerEmail).FirstOrDefault();
                                var ToUserContacts   = CompanyList.Where(x => x.ContactDetails != null && x.ContactDetails.Count > 0 && x.ContactDetails.Any(a => a.MAIL.ToLower() == SalesOfficer)).FirstOrDefault()?.ContactDetails;
                                var ToUser           = ToUserContacts?.Where(a => a.MAIL.ToLower() == SalesOfficer).FirstOrDefault();

                                FollowUpSetRes response        = new FollowUpSetRes();
                                FollowUpSetReq followUprequest = new FollowUpSetReq();
                                followUprequest.QRFID = request.QRFID;

                                FollowUpTask task = new FollowUpTask();
                                task.Task             = "Costing Approved";
                                task.FollowUpType     = "Internal";
                                task.FollowUpDateTime = DateTime.Now;

                                task.FromEmail = request.PlacerEmail;
                                if (FromUser != null)
                                {
                                    task.FromName       = FromUser.CommonTitle + " " + FromUser.FIRSTNAME + " " + FromUser.LastNAME;
                                    task.FromContact_Id = FromUser.Contact_Id;
                                }

                                task.ToEmail = SalesOfficer;
                                if (ToUser != null)
                                {
                                    task.ToName       = ToUser.CommonTitle + " " + ToUser.FIRSTNAME + " " + ToUser.LastNAME;
                                    task.ToContact_Id = ToUser.Contact_Id;
                                }

                                task.Status = "Replied";
                                task.Notes  = "Costing Approved";

                                var FollowUpTaskList = new List <FollowUpTask>();
                                FollowUpTaskList.Add(task);

                                followUprequest.FollowUp.Add(new FollowUp
                                {
                                    FollowUp_Id  = Guid.NewGuid().ToString(),
                                    FollowUpTask = FollowUpTaskList,
                                    CreateUser   = request.PlacerEmail,
                                    CreateDate   = DateTime.Now
                                });
                                await _quoteRepository.SetFollowUpForQRF(followUprequest);

                                #endregion
                            }
                            else
                            {
                                await _MongoContext.mQuote.FindOneAndUpdateAsync(
                                    Builders <mQuote> .Filter.Eq("QRFID", request.QRFID),
                                    Builders <mQuote> .Update.
                                    Set("CurrentPipeline", "Costing Pipeline").
                                    Set("CurrentPipelineStep", "Itinerary").
                                    Set("Remarks", request.Remarks).
                                    Set("CurrentPipelineSubStep", "").
                                    Set("QuoteResult", "Reject").
                                    Set("Status", "NewCostingPipeline").
                                    Set("EditUser", request.PlacerEmail).
                                    Set("EditDate", DateTime.Now)
                                    );

                                #region Add Followup
                                var CostingOfficer   = _MongoContext.mQRFPrice.AsQueryable().Where(a => a.QRFID == request.QRFID && a.IsCurrentVersion == true).FirstOrDefault()?.CostingOfficer?.ToLower().Trim();
                                var CompanyList      = _MongoContext.mCompanies.AsQueryable();
                                var FromUserContacts = CompanyList.Where(x => x.ContactDetails != null && x.ContactDetails.Count > 0 && x.ContactDetails.Any(a => a.MAIL.ToLower() == request.PlacerEmail)).FirstOrDefault()?.ContactDetails;
                                var FromUser         = FromUserContacts?.Where(a => a.MAIL.ToLower() == request.PlacerEmail.ToLower()).FirstOrDefault();
                                var ToUserContacts   = CompanyList.Where(x => x.ContactDetails != null && x.ContactDetails.Count > 0 && x.ContactDetails.Any(a => a.MAIL.ToLower() == CostingOfficer)).FirstOrDefault()?.ContactDetails;
                                var ToUser           = ToUserContacts?.Where(a => a.MAIL.ToLower() == CostingOfficer).FirstOrDefault();

                                FollowUpSetRes response        = new FollowUpSetRes();
                                FollowUpSetReq followUprequest = new FollowUpSetReq();
                                followUprequest.QRFID = request.QRFID;

                                FollowUpTask task = new FollowUpTask();
                                task.Task             = "Costing Changes Suggested";
                                task.FollowUpType     = "Internal";
                                task.FollowUpDateTime = DateTime.Now;

                                task.FromEmail = request.PlacerEmail;
                                if (FromUser != null)
                                {
                                    task.FromName       = FromUser.CommonTitle + " " + FromUser.FIRSTNAME + " " + FromUser.LastNAME;
                                    task.FromContact_Id = FromUser.Contact_Id;
                                }

                                task.ToEmail = CostingOfficer;
                                if (ToUser != null)
                                {
                                    task.ToName       = ToUser.CommonTitle + " " + ToUser.FIRSTNAME + " " + ToUser.LastNAME;
                                    task.ToContact_Id = ToUser.Contact_Id;
                                }

                                task.Status = "Request";
                                task.Notes  = "Costing Changes Suggested";

                                var FollowUpTaskList = new List <FollowUpTask>();
                                FollowUpTaskList.Add(task);

                                followUprequest.FollowUp.Add(new FollowUp
                                {
                                    FollowUp_Id  = Guid.NewGuid().ToString(),
                                    FollowUpTask = FollowUpTaskList,
                                    CreateUser   = request.PlacerEmail,
                                    CreateDate   = DateTime.Now
                                });
                                await _quoteRepository.SetFollowUpForQRF(followUprequest);

                                #endregion
                            }
                        }

                        #region Send Email
                        string doctype = "";
                        if (request.EnquiryPipeline.ToLower() == "costing pipeline")
                        {
                            if (request.IsApproveQuote)
                            {
                                doctype = DocType.COAPPROVAL;
                            }
                            else
                            {
                                doctype = DocType.COREJECT;
                            }
                        }
                        else if (request.EnquiryPipeline.ToLower() == "amendment pipeline")
                        {
                            doctype = DocType.COAPPROVAL;
                        }
                        else if (request.EnquiryPipeline.ToLower() == "costing approval pipeline")
                        {
                            if (request.IsApproveQuote)
                            {
                                doctype = DocType.CAPAPPROVAL;
                            }
                            else
                            {
                                doctype = DocType.CAPREJECT;
                            }
                        }

                        var objEmailGetReq = new EmailGetReq()
                        {
                            UserName        = request.PlacerUser,
                            UserEmail       = request.PlacerEmail,
                            PlacerUserId    = request.PlacerUserId,
                            QrfId           = request.QRFID,
                            Remarks         = request.Remarks,
                            DocumentType    = doctype,
                            EnquiryPipeline = request.EnquiryPipeline,
                            IsApproveQuote  = request.IsApproveQuote
                        };
                        var responseStatusMail = await _emailRepository.GenerateEmail(objEmailGetReq);

                        if (responseStatusMail == null || responseStatusMail.ResponseStatus == null || string.IsNullOrEmpty(responseStatusMail.ResponseStatus.Status))
                        {
                            responseStatusMail.ResponseStatus              = new ResponseStatus();
                            responseStatusMail.ResponseStatus.Status       = "Error";
                            responseStatusMail.ResponseStatus.ErrorMessage = "Mail not sent.";
                        }
                        #endregion

                        return(request.QRFID);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (MongoWriteException)
            {
                return(null);
            }
        }