/*
            select user1.firstName reqName ,user2.firstname pmName from
            campaign c ,users user1, users user2
            where c.requestorid=user1.id
            and c.assignedpmid=user2.id
         */
        public List<ACM.Model.CampaignRequestor> GetRequestorDashboard(int requestorId, int lobId, string status, bool isLobRequest)
        {
            ACM.Model.CampaignRequestor campaignRequestor = new ACM.Model.CampaignRequestor();
            List<ACM.Model.CampaignRequestor> campaignRequestorList = new List<ACM.Model.CampaignRequestor>();

            if (isLobRequest)
            {
                var result = (from camp in ACMContex.Campaigns
                              from user1 in ACMContex.Users
                              from user2 in ACMContex.Users
                              where camp.RequestorId == user1.UserId && camp.AssignedPMId == user2.UserId
                              select new { camp, firstname = user1.FirstName, lastname = user1.LastName, status = user1.Status, user1.LastName, firstname1 = user2.FirstName, firstname2 = user2.LastName }).ToList();
                foreach (var data in result)
                {
                    campaignRequestor = new ACM.Model.CampaignRequestor();
                    campaignRequestor.CampaignId = data.camp.CampaignId;
                    campaignRequestor.CampaignName = data.camp.CampaignName;
                    campaignRequestor.AssignedPMId = data.camp.AssignedPMId;

                    //int maxid = ACMContex.Users.Select(r => r.CampaignId).Max();

                    //shravan changes to sprint 2
                    campaignRequestor.LOBId = data.camp.User.UserId ;
                    campaignRequestor.AssignedPMFirstName = data.firstname1;
                    campaignRequestor.AssignedPMLastName = data.firstname2;
                    campaignRequestor.RequestorId =Convert.ToInt32 (  data.camp.RequestorId);
                    campaignRequestor.CampaignStartDate =Convert.ToDateTime(  data.camp.CampaignStartDate);
                    campaignRequestor.CampaingEndDate = Convert.ToDateTime(  data.camp.CampaingEndDate);
                    campaignRequestor.RequestorFirstName = data.firstname;
                    campaignRequestor.RequestorLastName = data.lastname;
                    campaignRequestor.CampaignStatus = data.camp.CampaignStatus;

                    if ((campaignRequestor.CampaignStatus == "Pending Review" && campaignRequestor.RequestorId == requestorId))
                        campaignRequestor.Action = "Cancel";
                    else
                        campaignRequestor.Action = "";

                    campaignRequestorList.Add(campaignRequestor);

                }
            }
            else
            {
                var result = (from camp in ACMContex.Campaigns
                              from user1 in ACMContex.Users
                              from user2 in ACMContex.Users
                              where camp.RequestorId == user1.UserId && camp.AssignedPMId == user2.UserId && camp.RequestorId == requestorId
                              select new { camp, firstname = user1.FirstName, lastname = user1.LastName, status = user1.Status, user1.LastName, firstname1 = user2.FirstName, firstname2 = user2.LastName }).ToList();
                foreach (var data in result)
                {
                    campaignRequestor = new ACM.Model.CampaignRequestor();
                    campaignRequestor.CampaignId = data.camp.CampaignId;
                    campaignRequestor.CampaignName = data.camp.CampaignName;
                    campaignRequestor.AssignedPMId = data.camp.AssignedPMId;

                    campaignRequestor.LOBId = data.camp.User.UserId ;
                    campaignRequestor.AssignedPMFirstName = data.firstname1;
                    campaignRequestor.AssignedPMLastName = data.firstname2;
                    campaignRequestor.RequestorId = Convert.ToInt32(  data.camp.RequestorId);
                    campaignRequestor.CampaignStartDate = Convert.ToDateTime(data.camp.CampaignStartDate);
                    campaignRequestor.CampaingEndDate =Convert.ToDateTime( data.camp.CampaingEndDate);
                    campaignRequestor.RequestorFirstName = data.firstname;
                    campaignRequestor.RequestorLastName = data.lastname;
                    campaignRequestor.CampaignStatus = data.camp.CampaignStatus;

                    if ((campaignRequestor.CampaignStatus == "Pending Review" && campaignRequestor.RequestorId == requestorId))
                        campaignRequestor.Action = "Cancel";
                    else
                        campaignRequestor.Action = "";

                    campaignRequestorList.Add(campaignRequestor);

                }
            }

            return campaignRequestorList;
        }
Esempio n. 2
0
        /*
         *  select user1.firstName reqName ,user2.firstname pmName from
         *  campaign c ,users user1, users user2
         *  where c.requestorid=user1.id
         *  and c.assignedpmid=user2.id
         */

        public List <ACM.Model.CampaignRequestor> GetRequestorDashboard(int requestorId, int lobId, string status, bool isLobRequest)
        {
            ACM.Model.CampaignRequestor        campaignRequestor     = new ACM.Model.CampaignRequestor();
            List <ACM.Model.CampaignRequestor> campaignRequestorList = new List <ACM.Model.CampaignRequestor>();

            if (isLobRequest)
            {
                var result = (from camp in ACMContex.Campaigns
                              from user1 in ACMContex.Users
                              from user2 in ACMContex.Users
                              where camp.RequestorId == user1.UserId && camp.AssignedPMId == user2.UserId
                              select new { camp, firstname = user1.FirstName, lastname = user1.LastName, status = user1.Status, user1.LastName, firstname1 = user2.FirstName, firstname2 = user2.LastName }).ToList();
                foreach (var data in result)
                {
                    campaignRequestor              = new ACM.Model.CampaignRequestor();
                    campaignRequestor.CampaignId   = data.camp.CampaignId;
                    campaignRequestor.CampaignName = data.camp.CampaignName;
                    campaignRequestor.AssignedPMId = data.camp.AssignedPMId;

                    //int maxid = ACMContex.Users.Select(r => r.CampaignId).Max();

                    //shravan changes to sprint 2
                    campaignRequestor.LOBId = data.camp.User.UserId;
                    campaignRequestor.AssignedPMFirstName = data.firstname1;
                    campaignRequestor.AssignedPMLastName  = data.firstname2;
                    campaignRequestor.RequestorId         = Convert.ToInt32(data.camp.RequestorId);
                    campaignRequestor.CampaignStartDate   = Convert.ToDateTime(data.camp.CampaignStartDate);
                    campaignRequestor.CampaingEndDate     = Convert.ToDateTime(data.camp.CampaingEndDate);
                    campaignRequestor.RequestorFirstName  = data.firstname;
                    campaignRequestor.RequestorLastName   = data.lastname;
                    campaignRequestor.CampaignStatus      = data.camp.CampaignStatus;

                    if ((campaignRequestor.CampaignStatus == "Pending Review" && campaignRequestor.RequestorId == requestorId))
                    {
                        campaignRequestor.Action = "Cancel";
                    }
                    else
                    {
                        campaignRequestor.Action = "";
                    }

                    campaignRequestorList.Add(campaignRequestor);
                }
            }
            else
            {
                var result = (from camp in ACMContex.Campaigns
                              from user1 in ACMContex.Users
                              from user2 in ACMContex.Users
                              where camp.RequestorId == user1.UserId && camp.AssignedPMId == user2.UserId && camp.RequestorId == requestorId
                              select new { camp, firstname = user1.FirstName, lastname = user1.LastName, status = user1.Status, user1.LastName, firstname1 = user2.FirstName, firstname2 = user2.LastName }).ToList();
                foreach (var data in result)
                {
                    campaignRequestor              = new ACM.Model.CampaignRequestor();
                    campaignRequestor.CampaignId   = data.camp.CampaignId;
                    campaignRequestor.CampaignName = data.camp.CampaignName;
                    campaignRequestor.AssignedPMId = data.camp.AssignedPMId;


                    campaignRequestor.LOBId = data.camp.User.UserId;
                    campaignRequestor.AssignedPMFirstName = data.firstname1;
                    campaignRequestor.AssignedPMLastName  = data.firstname2;
                    campaignRequestor.RequestorId         = Convert.ToInt32(data.camp.RequestorId);
                    campaignRequestor.CampaignStartDate   = Convert.ToDateTime(data.camp.CampaignStartDate);
                    campaignRequestor.CampaingEndDate     = Convert.ToDateTime(data.camp.CampaingEndDate);
                    campaignRequestor.RequestorFirstName  = data.firstname;
                    campaignRequestor.RequestorLastName   = data.lastname;
                    campaignRequestor.CampaignStatus      = data.camp.CampaignStatus;

                    if ((campaignRequestor.CampaignStatus == "Pending Review" && campaignRequestor.RequestorId == requestorId))
                    {
                        campaignRequestor.Action = "Cancel";
                    }
                    else
                    {
                        campaignRequestor.Action = "";
                    }

                    campaignRequestorList.Add(campaignRequestor);
                }
            }


            return(campaignRequestorList);
        }