Esempio n. 1
0
        public void AddByViewModel(LeadAssignmentSelectedPartnerViewModel viewModel, string userName)
        {
            foreach (var branchId in viewModel.PartnerBranchIds)
            {
                var assignment = new LeadAssignment()
                {
                    LeadId = viewModel.LeadId, PartnerBranchId = branchId
                };
                _context.LeadAssignments.Add(assignment);

                //this.SetState(assignment.Id, EnumState.SLA1, EnumStateActionTaken.Assigned, userName);
                this.SetState(assignment.Id, EnumState.SLA2, EnumStateActionTaken.Assigned, userName);
            }

            //_context.SaveChanges(); // will be commit at Controller
        }
Esempio n. 2
0
 private ReportInvoiceVM GetReportInvoiceVM(Lead lead, LeadAssignment assignment
                                            , LeadState submittedState, LeadAssignmentState assignedState, LeadAssignmentState acceptedState
                                            , LeadAssignmentState currentState, StateAction currentAction)
 {
     return(new ReportInvoiceVM()
     {
         LeadId = lead.Id,
         LeadDetails = lead.Details,
         SubmittedDateTime = DateHelper.ConvertFromUtc(submittedState.ActionTimestamp),
         SubmittedDateTimeString = DateHelper.ConvertFromUtc(submittedState.ActionTimestamp).ToShortDateString() + " " + DateHelper.ConvertFromUtc(submittedState.ActionTimestamp).ToShortTimeString(),
         LeadTypeId = lead.LeadType.Id,
         LeadTypeName = lead.LeadType.Name,
         LeadTypeImage = ImageHelper.PATH_CLIENT_LEAD_TYPE + lead.LeadType.Image,
         LeadTypePrice = lead.LeadType.Price,
         CustomerId = lead.Customer.Id,
         CustomerUnique = lead.Customer.ContactName + " (" + lead.Customer.EMail + ")",
         CustomerName = lead.Customer.ContactName,
         CustomerContactNumber = lead.Customer.ContactNumber,
         CustomerEmail = lead.Customer.EMail,
         CustomerBusinessName = lead.Customer.BusinessName,
         CustomerState = lead.Customer.Address.State,
         CustomerAddress = AddressHelper.MergeAddress(lead.Customer.Address),
         PartnerId = assignment.PartnerBranch.Partner.Id,
         PartnerName = assignment.PartnerBranch.Partner.Name,
         PartnerLogo = ImageHelper.PATH_CLIENT_PARTNER + assignment.PartnerBranch.Partner.Logo,
         PartnerAddress = AddressHelper.MergeAddress(assignment.PartnerBranch.Address),
         LeadAssignmentId = assignment.Id,
         AssignedDateTime = DateHelper.ConvertFromUtc(assignedState.ActionTimestamp),
         AssignedDateTimeString = DateHelper.ConvertFromUtc(assignedState.ActionTimestamp).ToShortDateString() + " " + DateHelper.ConvertFromUtc(assignedState.ActionTimestamp).ToShortTimeString(),
         AcceptedDateTime = DateHelper.ConvertFromUtc(acceptedState.ActionTimestamp),
         AcceptedDateTimeString = DateHelper.ConvertFromUtc(acceptedState.ActionTimestamp).ToShortDateString() + " " + DateHelper.ConvertFromUtc(acceptedState.ActionTimestamp).ToShortTimeString(),
         CurrentStateId = currentState.State.Id,
         CurrentStateName = currentState.State.Name,
         CurrentStateTag = StatusHelper.GetHtmlBadge(currentState.State.Id, currentState.State.Name),
         CurrentActionId = currentAction.Action.Id,
         CurrentActionName = currentAction.Action.ActionName
     });
 }
Esempio n. 3
0
 public void Update(LeadAssignment entity)
 {
     throw new NotImplementedException();
 }
Esempio n. 4
0
 public void Remove(LeadAssignment entity)
 {
     _context.Remove(entity);
     //_context.SaveChanges();
 }
Esempio n. 5
0
        protected LeadAssignmentVM GetLeadAssignmentViewModel(LeadAssignment item)
        {
            var itemVM = new LeadAssignmentVM();

            itemVM.Id     = item.Id;
            itemVM.LeadId = item.LeadId;

            if (item.Lead != null)
            {
                itemVM.LeadDetails = item.Lead.Details;

                if (item.Lead.LeadType != null)
                {
                    itemVM.LeadTypeName  = item.Lead.LeadType.Name;
                    itemVM.LeadTypeImage = ImageHelper.PATH_CLIENT_LEAD_TYPE + item.Lead.LeadType.Image;
                }

                if (item.Lead.Customer != null)
                {
                    itemVM.CustomerId     = item.Lead.Customer.Id;
                    itemVM.CustomerUnique = String.Format("{0} ({1})", item.Lead.Customer.ContactName, item.Lead.Customer.EMail);

                    itemVM.CustomerName          = item.Lead.Customer.ContactName;
                    itemVM.CustomerBusinessName  = item.Lead.Customer.BusinessName;
                    itemVM.CustomerEMail         = item.Lead.Customer.EMail;
                    itemVM.CustomerContactNumber = item.Lead.Customer.ContactNumber;
                    itemVM.CustomerStreetAddress = item.Lead.Customer.Address.StreetAddress;
                    itemVM.CustomerSuburb        = item.Lead.Customer.Address.Suburb;
                    itemVM.CustomerState         = item.Lead.Customer.Address.State;
                    itemVM.CustomerPostCode      = item.Lead.Customer.Address.PostCode;
                    itemVM.CustomerAddress       = AddressHelper.MergeAddress(itemVM.CustomerStreetAddress, itemVM.CustomerSuburb, itemVM.CustomerState, itemVM.CustomerPostCode);

                    itemVM.CustomerDetails = String.Format("Business: <b>{0}</b><br>Tel: <b>{1}</b><br>Address: <b>{2}</b>", itemVM.CustomerBusinessName, itemVM.CustomerContactNumber, itemVM.CustomerAddress);
                }
            }

            itemVM.PartnerId   = item.PartnerBranch.Partner.Id;
            itemVM.PartnerName = item.PartnerBranch.Partner.Name;
            itemVM.PartnerLogo = ImageHelper.PATH_CLIENT_PARTNER + item.PartnerBranch.Partner.Logo;

            itemVM.PartnerBranchId            = item.PartnerBranch.Id;
            itemVM.PartnerBranchStreetAddress = item.PartnerBranch.Address.StreetAddress;
            itemVM.PartnerBranchSuburb        = item.PartnerBranch.Address.Suburb;
            itemVM.PartnerBranchState         = item.PartnerBranch.Address.State;
            itemVM.PartnerBranchPostCode      = item.PartnerBranch.Address.PostCode;
            itemVM.PartnerBranchAddress       = AddressHelper.MergeAddress(itemVM.PartnerBranchStreetAddress, itemVM.PartnerBranchSuburb, itemVM.PartnerBranchState, itemVM.PartnerBranchPostCode);

            // Current status
            var currentStatus = item.LeadAssignmentStates.Where(w => w.StateId != nameof(EnumState.S0)).OrderByDescending(o => o.ActionTimestamp).FirstOrDefault();

            itemVM.StatusId   = currentStatus.State.Id;
            itemVM.StatusName = currentStatus.State.Name;
            itemVM.StatusTag  = StatusHelper.GetHtmlBadge(currentStatus.State.Id, currentStatus.State.Name);
            itemVM.RatingTag  = RatingHelper.GetHtmlRatingTag(item.Comment, item.CommentedBy, item.CommentedOn);

            if (string.IsNullOrEmpty(_userRoleName))
            {
                _userRoleName = _accountManager.GetRoleAsync(_accountManager.GetUserAsync(User.Identity.Name).Result).Result;
            }

            // Actions of current status
            var actions = currentStatus.State.StateActions.Where(w => this.IsActionAllowed(w.Action.Id, _userRoleName)).Select(s => new ActionLeadAssignmentVM
            {
                Id               = s.ActionId,
                LeadId           = itemVM.LeadId,
                PartnerBranchId  = itemVM.PartnerBranchId,
                LeadAssignmentId = itemVM.Id,
                CustomerEmail    = itemVM.CustomerEMail,
                PartnerEmails    = _salesRepo.GetByPartner(itemVM.PartnerId).Select(person => person.EMail).ToList(),
                ControllerName   = s.Action.ControllerName,
                ActionName       = s.Action.ActionName,
                ActionTarget     = s.Action.ActionTarget,
                RequestType      = s.Action.RequestType,
                DisplayName      = s.Action.DisplayName,
                Icon             = s.Action.Icon,
                NextStateId      = s.Action.NextStateId,
                Rating           = new Rating()
                {
                    Rate = item.Rate, Comment = item.Comment ?? string.Empty, CommentedOn = item.CommentedOn, CommentedBy = item.CommentedBy
                }
            }).ToList();

            itemVM.Actions = actions;

            // CreatedWhen
            var firstSssignedOn = item.LeadAssignmentStates.OrderBy(o => o.ActionTimestamp).FirstOrDefault();

            itemVM.AssignedOn = DateHelper.ConvertFromUtc(firstSssignedOn.ActionTimestamp).Date;

            // History
            var histories = item.LeadAssignmentStates
                            .OrderByDescending(o => o.ActionTimestamp)
                            //.Where(w => w.StateId != currentStatus.StateId) // *show all
                            .Select(s => HistoryHelper.GetHtmlHistoryLine(DateHelper.ConvertFromUtc(s.ActionTimestamp), s.Action.ToLower(), s.Actor));

            itemVM.History = HistoryHelper.GetHtmlHistoryTag(histories.ToList());

            return(itemVM);
        }