示例#1
0
        public ActionResult SaveManualAllocation(string Selected)
        {
            AVOAIALifeEntities Context            = new AVOAIALifeEntities();
            ManualAllocation   objAllocationModel = new ManualAllocation();

            objAllocationModel.objLstAllocationProposals = new List <AllocationProposals>();

            var SelectedArray = Selected.Split(',');

            for (int i = 0; i < SelectedArray.Count(); i++)
            {
                var Combined            = SelectedArray[i].Split('-');
                var ProposalNo          = Combined[0] + "-" + Combined[1];
                var LoginID             = Combined[2];
                var UserID              = Context.tblUserDetails.Where(a => a.LoginID == LoginID).Select(a => a.UserID).FirstOrDefault();
                AllocationProposals obj = new AllocationProposals();
                obj.ISSelected = true;
                obj.ProposalNo = ProposalNo;
                obj.AssignTo   = UserID.ToString();
                objAllocationModel.objLstAllocationProposals.Add(obj);
            }

            objAllocationModel = objAllocationBusiness.SaveManualAllocation(objAllocationModel);

            return(Json(objAllocationModel.Message, JsonRequestBehavior.AllowGet));
        }
示例#2
0
 public ManualAllocation ResetManualAllocation(ManualAllocation objAllocationModel)
 {
     #region Call API
     objAllocationModel = WebApiLogic.GetPostComplexTypeToAPI <ManualAllocation>(objAllocationModel, "ResetManualAllocation", "Allocation");
     #endregion
     return(objAllocationModel);
 }
示例#3
0
        public ManualAllocation SaveManualAllocation(ManualAllocation objAllocationModel)
        {
            try
            {
                using (AVOAIALifeEntities Context = new AVOAIALifeEntities())
                {
                    foreach (var Item in objAllocationModel.objLstAllocationProposals.Where(a => a.ISSelected == true).ToList())
                    {
                        if (!string.IsNullOrEmpty(Item.AssignTo))
                        {
                            DateTime Date = DateTime.Now;

                            var policy = Context.tblPolicies.Where(a => a.ProposalNo == Item.ProposalNo).FirstOrDefault();
                            if (policy != null)
                            {
                                decimal PolicyID         = policy.PolicyID;
                                var     PolicyAllocation = Context.tblPolicyUWAllocations.Where(a => a.PolicyID == PolicyID).FirstOrDefault();
                                if (PolicyAllocation != null)
                                {
                                    PolicyAllocation.AllocatedFrom = PolicyAllocation.AllocatedTo;
                                    PolicyAllocation.AllocatedTo   = Item.AssignTo.ToUpper();
                                    PolicyAllocation.AllocatedDate = Date;
                                    policy.IsAllocated             = true;
                                    policy.ModifiedDate            = Date;
                                }
                                else
                                {
                                    tblPolicyUWAllocation objPolicyUWAllocation = new tblPolicyUWAllocation();
                                    objPolicyUWAllocation.PolicyID      = PolicyID;
                                    objPolicyUWAllocation.AllocatedFrom = string.Empty;
                                    objPolicyUWAllocation.AllocatedTo   = Item.AssignTo;
                                    objPolicyUWAllocation.AllocatedDate = Date;
                                    objPolicyUWAllocation.Remarks       = string.Empty;
                                    objPolicyUWAllocation.CreatedDate   = Date;
                                    Context.tblPolicyUWAllocations.Add(objPolicyUWAllocation);
                                    policy.IsAllocated  = true;
                                    policy.ModifiedDate = Date;
                                }
                            }

                            Context.SaveChanges();
                        }
                    }
                }
                objAllocationModel.Message = "Success";
            }
            catch (Exception ex)
            {
                log4net.GlobalContext.Properties["ErrorCode"] = Codes.GetErrorCode();
                Logger.Error(ex);
                objAllocationModel.Message = "Error";
            }
            return(objAllocationModel);
        }
        public ManualAllocation ResetManualAllocation(ManualAllocation objAllocationModel)
        {
            AllocationLogic objLogic = new AllocationLogic();

            return(objLogic.ResetManualAllocation(objAllocationModel));
        }
        public ManualAllocation ManualAllocationDetails(ManualAllocation objAllocationModel)
        {
            AllocationLogic objLogic = new AllocationLogic();

            return(objLogic.ManualAllocationDetails(objAllocationModel));
        }
示例#6
0
        public ManualAllocation ResetManualAllocation(ManualAllocation objAllocationModel)
        {
            AllocationBusiness objLogic = new AllocationBusiness();

            return(objLogic.ResetManualAllocation(objAllocationModel));
        }
示例#7
0
        public ManualAllocation ManualAllocationDetails(ManualAllocation objAllocationModel)
        {
            try
            {
                using (AVOAIALifeEntities Context = new AVOAIALifeEntities())
                {
                    string RoleID  = Context.AspNetRoles.Where(a => a.Name == "UW User").FirstOrDefault().Id;
                    var    idParam = new SqlParameter
                    {
                        ParameterName = "@RoleId",
                        Value         = RoleID
                    };
                    List <string> UserIDs = Context.Database.SqlQuery <string>(
                        "exec GetUsersByRoleId @RoleId", idParam).ToList();

                    if (UserIDs != null)
                    {
                        objAllocationModel.LstUWName = (from aspnetusers in Context.AspNetUsers.Where(a => UserIDs.Contains(a.Id) && a.LockoutEndDateUtc == null)
                                                        join userdetails in Context.tblUserDetails
                                                        on aspnetusers.UserName equals userdetails.LoginID
                                                        select new MasterListItem
                        {
                            Text = aspnetusers.UserName,
                            Value = aspnetusers.Id
                        }).ToList();
                        int i = 0;
                        objAllocationModel.objLstAllocationProposals = (from Proposal in Context.tblPolicies.Where(a => a.IsAllocated == false)
                                                                        select new AllocationProposals
                        {
                            ProposalNoDisplay = Proposal.ProposalNo,
                            ProposalNo = Proposal.ProposalNo,
                            PolicyID = Proposal.PolicyID
                        }).OrderByDescending(a => a.PolicyID).ToList().Select((item, index) => new AllocationProposals
                        {
                            ProposalNoDisplay = item.ProposalNoDisplay,
                            ProposalNo        = item.ProposalNo,
                            Index             = index,
                            PolicyID          = item.PolicyID
                        }).ToList();

                        objAllocationModel.objLstResetProposals = (from Proposal in Context.tblPolicies.Where(a => a.PolicyStageStatusID == 193) // Ref to UW
                                                                   join UWAllocation in Context.tblPolicyUWAllocations
                                                                   on Proposal.PolicyID equals UWAllocation.PolicyID
                                                                   join ASpnetUsers in Context.AspNetUsers
                                                                   on UWAllocation.AllocatedTo equals ASpnetUsers.Id
                                                                   where Proposal.ModifiedDate == UWAllocation.AllocatedDate
                                                                   select new AllocationProposals
                        {
                            ProposalNoDisplay = Proposal.ProposalNo,
                            ProposalNo = Proposal.ProposalNo,
                            UWName = ASpnetUsers.UserName,
                            PolicyID = Proposal.PolicyID
                        }).OrderByDescending(a => a.PolicyID).ToList().Select((item, index) => new AllocationProposals
                        {
                            ProposalNoDisplay = item.ProposalNoDisplay,
                            ProposalNo        = item.ProposalNo,
                            UWName            = item.UWName,
                            Index             = index,
                            PolicyID          = item.PolicyID
                        }).ToList();

                        if (objAllocationModel.objLstAllocationProposals == null)
                        {
                            objAllocationModel.objLstAllocationProposals = new List <AllocationProposals>();
                        }

                        if (objAllocationModel.objLstResetProposals == null)
                        {
                            objAllocationModel.objLstResetProposals = new List <AllocationProposals>();
                        }
                    }


                    objAllocationModel.Message = "Success";
                    return(objAllocationModel);
                }
            }
            catch (Exception ex)
            {
                log4net.GlobalContext.Properties["ErrorCode"] = Codes.GetErrorCode();
                Logger.Error(ex);
                objAllocationModel.Message = "Error";
                return(objAllocationModel);
            }
        }