Ejemplo n.º 1
0
        public ActionResult Getlist(string name, string Notes, int listid, int companyid, string emailaddes)
        {
            var data = new List <ContactDetails>();

            try
            {
                var contactdata = context.SpContactFilter(listid, companyid).ToList();
                if (contactdata.Count() > 0)
                {
                    var companyname = context.SPgetCompdetailsbycompid(companyid).FirstOrDefault().name;

                    if ((name != "" && Notes != ""))
                    {
                        data = (from con in contactdata
                                where
                                (
                                    (name == null || name == "") || con.contactfullname.ToUpper().Contains(name.ToUpper())) &&
                                ((Notes == "" || Notes == null) || con.combinednotes.Trim().Replace("\r", "").
                                 Replace("\n", "").Replace(System.Environment.NewLine, "").Replace(" ", "").
                                 Contains(Notes.Trim().Replace("\r", "").Replace("\n", "").Replace(System.Environment.NewLine, "").Replace(" ", "")))
                                select new ContactDetails
                        {
                            contactid = con.contactid,
                            companyid = con.companyid,
                            contactfullname = con.contactfullname,
                            titlestandard = con.titlestandard,
                            contactphone = con.contactphone,
                            contactcellphone = con.contactcellphone,
                            contactemail = con.contactemail,
                            listid = con.listid,
                            linkedinprofileurl = con.linkedinprofileurl,
                            combinednotes = con.combinednotes,
                            compname = companyname,
                            ResumeFile = con.ResumeFilePath
                        }).Distinct().ToList();

                        ViewBag.ConEmail = emailaddes;
                    }
                    else if (Notes != "" && Notes != null)
                    {
                        contactdata = contactdata.Where(x => x.combinednotes != null).ToList();
                        data        = (from con in contactdata
                                       where
                                       ((con.combinednotes.Trim().Replace("\r", "").
                                         Replace("\n", "").Replace(System.Environment.NewLine, "").Replace(" ", "").
                                         Contains(Notes.Trim().Replace("\r", "").
                                                  Replace("\n", "").Replace(System.Environment.NewLine, "").Replace(" ", ""))))
                                       select new ContactDetails
                        {
                            contactid = con.contactid,
                            companyid = con.companyid,
                            contactfullname = con.contactfullname,
                            titlestandard = con.titlestandard,
                            contactphone = con.contactphone,
                            contactcellphone = con.contactcellphone,
                            contactemail = con.contactemail,
                            listid = con.listid,
                            linkedinprofileurl = con.linkedinprofileurl,
                            combinednotes = con.combinednotes,
                            compname = companyname,
                            ResumeFile = con.ResumeFilePath
                        }).Distinct().ToList();

                        ViewBag.ConEmail = emailaddes;
                    }
                    else if (name != "" && name != null)
                    {
                        contactdata = contactdata.Where(x => x.contactfullname != null).ToList();
                        data        = (from con in contactdata
                                       where
                                       (con.contactfullname.ToUpper().Contains(name.ToUpper()))
                                       select new ContactDetails
                        {
                            contactid = con.contactid,
                            companyid = con.companyid,
                            contactfullname = con.contactfullname,
                            titlestandard = con.titlestandard,
                            contactphone = con.contactphone,
                            contactcellphone = con.contactcellphone,
                            contactemail = con.contactemail,
                            listid = con.listid,
                            linkedinprofileurl = con.linkedinprofileurl,
                            combinednotes = con.combinednotes,
                            compname = companyname,
                            ResumeFile = con.ResumeFilePath
                        }).Distinct().ToList();
                        ViewBag.ConEmail = emailaddes;
                    }
                    else
                    {
                        //  data = (from con in contactdata
                        //          where
                        //            (
                        //            (name == null || name == "") || con.contactfullname.ToUpper().Contains(name.ToUpper())) ||
                        //          ((Notes == "" || Notes == null) || con.combinednotes.Trim().Replace("\r", "").
                        //          Replace("\n", "").Replace(System.Environment.NewLine, "").Replace(" ", "").
                        //Contains(Notes.Trim().Replace("\r", "").Replace("\n", "").Replace(System.Environment.NewLine, "").Replace(" ", "")))

                        data = (from con in contactdata
                                select new ContactDetails
                        {
                            contactid = con.contactid,
                            companyid = con.companyid,
                            contactfullname = con.contactfullname,
                            titlestandard = con.titlestandard,
                            contactphone = con.contactphone,
                            contactcellphone = con.contactcellphone,
                            contactemail = con.contactemail,
                            listid = con.listid,
                            linkedinprofileurl = con.linkedinprofileurl,
                            combinednotes = con.combinednotes,
                            compname = companyname,
                            ResumeFile = con.ResumeFilePath
                        }).Distinct().ToList();

                        ViewBag.ConEmail = emailaddes;
                    }
                }
            }
            catch (Exception ex)
            {
                cm.ErrorExceptionLogingByService(ex.ToString(), "ProspectViewCompany" + ":" + new StackTrace().GetFrame(0).GetMethod().Name, "Getlist", "NA", "NA", "NA", "WEB");
            }
            return(View(data));
        }