コード例 #1
0
        public object RunRequest(AddQuotationRequest request)
        {
            var response = new AddQuotationResponse();
            var Lead     = _dbContext.Lead.Where(x => x.Id == request.LeadId).FirstOrDefault();

            Lead.Quotation        = request.Quotation;
            Lead.QuotationStatus  = request.QuotationStatus;
            Lead.QuotationRemarks = request.QuotationRemarks;

            var Admins = from user in _dbContext.AspNetUsers
                         where user.AspNetRoles.Any(r => r.Name == Roles.Admin.ToString())
                         select user;

            foreach (var admin in Admins)
            {
                var notification = new LMS.Models.EntityModel.Notification()
                {
                    AgentId   = admin.Agent.FirstOrDefault().Id,
                    CreatedAt = DateTime.Now,
                    Date      = DateTime.Now.Date,
                    Link      = "/Lead/Detail?Id=" + request.LeadId,
                    Content   = "Quoatation has been provided on Lead #" + request.LeadId,
                    IsRead    = false
                };
                var result = _dbContext.Notification.Add(notification);
            }
            _dbContext.SaveChanges();
            return(response);
        }
コード例 #2
0
        public object RunRequest(AssignLeadRequest request)
        {
            var response     = new AssignLeadResponse();
            var Notification = new LMS.Models.EntityModel.Notification();
            var Lead         = _dbContext.Lead.Where(x => x.Id == request.Id).FirstOrDefault();

            if (request.Type == AssigningType.Lead.ToString())
            {
                Lead.AssignedToId   = request.AssignedUserId;
                Lead.LeadAssignedOn = DateTime.Now;
            }
            if (request.Type == AssigningType.PMD.ToString())
            {
                Lead.PmdAssignedOn = DateTime.Now;
                Lead.AssignedPmdId = request.AssignedUserId;
            }
            if (request.Type == AssigningType.PreSale.ToString())
            {
                Lead.PresaleAssignedOn = DateTime.Now;
                Lead.AssignedPreSaleId = request.AssignedUserId;
            }

            Notification.AgentId   = request.AssignedUserId;
            Notification.CreatedAt = DateTime.Now;
            Notification.Date      = DateTime.Now.Date;
            Notification.Content   = "Lead # " + request.Id + " Has been assigned to you!";
            Notification.Link      = "/Lead/Detail?Id=" + request.Id;
            Notification.IsRead    = false;
            var result = _dbContext.Notification.Add(Notification);

            _dbContext.SaveChanges();
            return(response);
        }
        public object RunRequest(EditLeadStatusRequest request)
        {
            var response = new EditLeadStatusResponse();
            var Lead     = _dbContext.Lead.Where(x => x.Id == request.LeadId).FirstOrDefault();
            var Content  = "";

            if (Lead.IsApproved == true)
            {
                Lead.LeadStatus = (int)LeadStatus.Completed;
                Content         = "Lead #" + request.LeadId + "has been Completed and Closed";
            }
            //if(Lead.IsApproved == false)
            //{
            //    Content = "Lead #" + request.LeadId + "has been Cancled and Closed";
            //}
            var Admins = from user in _dbContext.AspNetUsers
                         where user.AspNetRoles.Any(r => r.Name == Roles.Admin.ToString())
                         select user;

            foreach (var admin in Admins)
            {
                var notification = new LMS.Models.EntityModel.Notification()
                {
                    AgentId   = admin.Agent.FirstOrDefault().Id,
                    CreatedAt = DateTime.Now,
                    Date      = DateTime.Now.Date,
                    Link      = "/Lead/Detail?Id=" + request.LeadId,
                    Content   = Content,
                    IsRead    = false
                };
                var result = _dbContext.Notification.Add(notification);
            }

            if (Lead.AssignedPmdId != null)
            {
                var PMDNotification = new LMS.Models.EntityModel.Notification();
                PMDNotification.AgentId   = Lead.AssignedPmdId;
                PMDNotification.Link      = "/Lead/Detail?Id=" + request.LeadId;
                PMDNotification.CreatedAt = DateTime.Now;
                PMDNotification.Date      = DateTime.Now.Date;
                PMDNotification.Content   = Content;
                var result = _dbContext.Notification.Add(PMDNotification);
            }
            if (Lead.AssignedPreSaleId != null)
            {
                var PresalesNotification = new LMS.Models.EntityModel.Notification();
                PresalesNotification.AgentId   = Lead.AssignedPreSaleId;
                PresalesNotification.Link      = "/Lead/Detail?Id=" + request.LeadId;
                PresalesNotification.CreatedAt = DateTime.Now;
                PresalesNotification.Date      = DateTime.Now.Date;
                PresalesNotification.Content   = Content;
                var result = _dbContext.Notification.Add(PresalesNotification);
            }
            if (Lead.AssignedToId != null)
            {
                var AssignedSalesNotification = new LMS.Models.EntityModel.Notification();
                AssignedSalesNotification.AgentId   = Lead.AgentId;
                AssignedSalesNotification.Link      = "/Lead/Detail?Id=" + request.LeadId;
                AssignedSalesNotification.CreatedAt = DateTime.Now;
                AssignedSalesNotification.Date      = DateTime.Now.Date;
                AssignedSalesNotification.Content   = Content;
                var result = _dbContext.Notification.Add(AssignedSalesNotification);
            }
            _dbContext.SaveChanges();
            return(response);
        }
コード例 #4
0
        public object RunRequest(AddApprovalRequest request)
        {
            var response = new AddApprovalResponse();
            var Lead     = _dbContext.Lead.Where(x => x.Id == request.LeadId).FirstOrDefault();

            Lead.IsApproved = request.IsApproved;
            var Content = "";

            if (Lead.IsApproved == false)
            {
                Lead.LeadStatus = (int)LeadStatus.Cancelled;
                Content         = "Lead #" + request.LeadId + "Has been Disapproved";
            }
            if (Lead.IsApproved == true)
            {
                Content = "Lead #" + request.LeadId + "Has been Approved";
            }


            Lead.AdminRemarks = request.AdminRemarks;
            if (Lead.AssignedPmdId != null)
            {
                var PMDNotification = new LMS.Models.EntityModel.Notification();
                PMDNotification.AgentId   = Lead.AssignedPmdId;
                PMDNotification.Link      = "/Lead/Detail?Id=" + request.LeadId;
                PMDNotification.CreatedAt = DateTime.Now;
                PMDNotification.Date      = DateTime.Now.Date;
                PMDNotification.Content   = Content;
                var result = _dbContext.Notification.Add(PMDNotification);
            }
            if (Lead.AssignedPreSaleId != null)
            {
                var PresalesNotification = new LMS.Models.EntityModel.Notification();
                PresalesNotification.AgentId   = Lead.AssignedPreSaleId;
                PresalesNotification.Link      = "/Lead/Detail?Id=" + request.LeadId;
                PresalesNotification.CreatedAt = DateTime.Now;
                PresalesNotification.Date      = DateTime.Now.Date;
                PresalesNotification.Content   = Content;
                var result = _dbContext.Notification.Add(PresalesNotification);
            }
            if (Lead.AgentId != null)
            {
                var SalesNotification = new LMS.Models.EntityModel.Notification();
                SalesNotification.AgentId   = Lead.AgentId;
                SalesNotification.Link      = "/Lead/Detail?Id=" + request.LeadId;
                SalesNotification.CreatedAt = DateTime.Now;
                SalesNotification.Date      = DateTime.Now.Date;
                SalesNotification.Content   = Content;
                var result = _dbContext.Notification.Add(SalesNotification);
            }
            if (Lead.AssignedToId != null)
            {
                var AssignedSalesNotification = new LMS.Models.EntityModel.Notification();
                AssignedSalesNotification.AgentId   = Lead.AgentId;
                AssignedSalesNotification.Link      = "/Lead/Detail?Id=" + request.LeadId;
                AssignedSalesNotification.CreatedAt = DateTime.Now;
                AssignedSalesNotification.Date      = DateTime.Now.Date;
                AssignedSalesNotification.Content   = Content;
                var result = _dbContext.Notification.Add(AssignedSalesNotification);
            }
            _dbContext.SaveChanges();
            return(response);
        }