Пример #1
0
        public static Prospect Savenewprospect(Prospect value, int StaffID, string ApplicationContext)
        {
            Prospect returnvalue = new Prospect();
            Exceptionerror = "";
            try
            {
                using (ProspectEntityModel context = new ProspectEntityModel())
                {
                    AlignProspect obj = new AlignProspect();
                    obj.FName = value.FName;
                    obj.LName = value.LName;
                    obj.Address1 = value.Address1;
                    obj.Address2 = value.Address2;
                    obj.City = value.City;
                    obj.State = value.State;
                    obj.Country = value.Country;
                    obj.ZipCode = value.ZipCode;
                    obj.Phone1 = value.Phone1;
                    obj.Phone2 = value.Phone2;
                    obj.EmailID = value.Email;
                    obj.Sex = value.Sex;
                    obj.DOB = value.DOB.ToShortDateString();
                    obj.CreatedByUser = StaffID;
                    obj.GymID = Convert.ToInt16(value.GymId);
                    obj.TimeStampCreated = DateTime.Now.ToString();
                    obj.TimeStampModified = DateTime.Now.ToString();
                    obj.ModifiedByUserId = StaffID;
                    obj.ModifiedContext = ApplicationContext;
                    obj.CreationNote = ApplicationContext;
                    obj.TrainerId = StaffID;
                    obj.UserType = 1;
                    obj.EmailOptOut = value.EmailOptOut;
                    context.AlignProspects.Add(obj);
                    context.SaveChanges();
                    returnvalue = ProspectDetail.ProspectDetailByProspectID(obj.UserID);
                }
            }
            catch(Exception ex)
            {
                Exceptionerror = ex.Message;
            }

            return returnvalue;
        }
Пример #2
0
 public static Prospect DeleteProspect(int ProspectID, int StaffID, string ApplicationContext)
 {
     Prospect returnvalue = new Prospect();
     using (ProspectEntityModel context = new ProspectEntityModel())
     {
         var result = context.AlignProspects.Where(row => row.UserID == ProspectID).ToList();
         if (result.Count > 0)
         {
             foreach (var obj in result)
             {
                 obj.TimeStampModified = DateTime.Now.ToString();
                 obj.ModifiedByUserId = StaffID;
                 obj.ModifiedContext = ApplicationContext;
                 obj.IsDeleted = true;
                 context.SaveChanges();
             }
             returnvalue = ProspectDetail.ProspectDetailByProspectID(ProspectID);
         }
     }
     return returnvalue;
 }
Пример #3
0
        public static Prospect UpdateExistingprospect(Prospect value, int ProspectID, int StaffID, string ApplicationContext)
        {
            Prospect returnvalue = new Prospect();
            Exceptionerror = "";
            try
            {
                using (ProspectEntityModel context = new ProspectEntityModel())
                {
                    var result = context.AlignProspects.Where(row => row.UserID == ProspectID).ToList();
                    if (result.Count > 0)
                    {
                        foreach (var obj in result)
                        {
                            obj.FName = value.FName;
                            obj.LName = value.LName;
                            obj.Address1 = value.Address1;
                            obj.Address2 = value.Address2;
                            obj.City = value.City;
                            obj.State = value.State;
                            obj.Country = value.Country;
                            obj.ZipCode = value.ZipCode;
                            obj.Phone1 = value.Phone1;
                            obj.Phone2 = value.Phone2;
                            obj.EmailID = value.Email;
                            obj.Sex = value.Sex;
                            obj.DOB = value.DOB.ToShortDateString();
                            obj.CreatedByUser = StaffID;
                            obj.GymID = Convert.ToInt16(value.GymId);
                            obj.TimeStampModified = DateTime.Now.ToString();
                            obj.ModifiedByUserId = StaffID;
                            obj.ModifiedContext = ApplicationContext;
                            obj.TrainerId = StaffID;
                            obj.UserType = 1;
                            if (value.ProfileId > 0)
                            {
                                obj.ProfileID = value.ProfileId;
                                obj.ConvertedByUser = StaffID;
                            }
                            obj.EmailOptOut = value.EmailOptOut;
                            context.SaveChanges();
                            returnvalue.ProspectId = obj.UserID;
                        }
                        returnvalue = ProspectDetail.ProspectDetailByProspectID(ProspectID);
                    }
                }
            }
            catch(Exception ex)
            {
                Exceptionerror = ex.Message;
            }

            return returnvalue;
        }
Пример #4
0
        public static List<ProspectSearch> QuickProspectSearch(int GymID, string searchstr, string type, string Sort)
        {
            List<ProspectSearch> returnvalue = new List<ProspectSearch>();
            using (ProspectEntityModel context = new ProspectEntityModel())
            {
                var result = (from pros in context.AlignProspects
                              where ((pros.ProfileID == null && GymID != 0 && pros.GymID == GymID) || (pros.ProfileID == null && GymID == 0)) && ((pros.FName.Trim() + " " + pros.LName.Trim()).ToLower().StartsWith(searchstr.ToLower()) || pros.LName.Trim().ToLower().StartsWith(searchstr.ToLower()))
                              select new
                              {
                                  UserID = pros.UserID,
                                  FName = pros.FName.Trim(),
                                  LName = pros.LName.Trim(),
                                  Phone1 = pros.Phone1,
                                  TimeStampCreated = pros.TimeStampCreated,
                                  TimeStampModified = pros.TimeStampModified,
                                  ProfileId = pros.ProfileID,
                                  TrainerID = pros.TrainerId,
                                  GymId = pros.GymID,
                                  CreatedByUser = pros.CreatedByUser ?? 0,
                                  ModifiedByUserId = pros.ModifiedByUserId ?? 0,
                                  ModifiedContext = pros.ModifiedContext ?? "",
                                  CreationNote = pros.CreationNote ?? "",
                                  ConvertedByUser = pros.ConvertedByUser ?? 0,
                                  MemberBeforeProspect = pros.MemberBeforeProspect,
                                  IsDeleted = pros.IsDeleted
                              }).ToList();

                if (type.Contains("phone"))
                {
                    result = result.Where(row => row.Phone1.Contains(searchstr.ToLower())).ToList();
                }
                else if (type.Contains("combo"))
                {
                    result = result.Where((row => row.Phone1.ToLower().Contains(searchstr.ToLower()) && (row.FName.Trim() + " " + row.LName.Trim()).ToLower().StartsWith(searchstr.ToLower()) || row.LName.Trim().ToLower().StartsWith(searchstr.ToLower()))).ToList();
                }

                if (Sort.Contains("-firstlast"))
                {
                    result = result.OrderByDescending(row => row.FName).ThenByDescending(row => row.LName).ToList();
                }
                else if (Sort.Contains("-lastfirst"))
                {
                    result = result.OrderByDescending(row => row.LName).ThenByDescending(row => row.FName).ToList();
                }
                else if (Sort.Contains("firstlast"))
                {
                    result = result.OrderBy(row => row.FName).ThenBy(row => row.LName).ToList();
                }
                else if (Sort.Contains("lastfirst"))
                {
                    result = result.OrderBy(row => row.LName).ThenBy(row => row.FName).ToList();
                }
                else if (Sort.Contains("-recent"))
                {
                    result = result.OrderBy(row => Convert.ToDateTime(row.TimeStampModified).Date).ToList();
                }
                else if (Sort.Contains("recent"))
                {
                    result = result.OrderByDescending(row => Convert.ToDateTime(row.TimeStampModified).Date).ToList();
                }

                if (result.Count() > 0)
                {
                    foreach (var i in result)
                    {
                        ProspectSearch obj = new ProspectSearch();
                        obj.ProspectId = i.UserID;
                        obj.ProfileId = i.ProfileId ?? 0;
                        obj.GymId = int.Parse(i.GymId.ToString());
                        obj.FullName = i.FName+" "+i.LName;

                        obj.Phone1 = i.Phone1 ?? "";
                        returnvalue.Add(obj);
                    }
                }
            }

            return returnvalue;
        }
Пример #5
0
        public static List<Prospect> ProspectMemberDetail(int GymID, int StaffID, bool IsTrainer,string Sort)
        {
            List<Prospect> returnvalue = new List<Prospect>();
            using (ProspectEntityModel context = new ProspectEntityModel())
            {
                var result = (from pros in context.AlignProspects
                             where ((pros.ProfileID == null && GymID != 0 && pros.GymID == GymID) || (pros.ProfileID == null && GymID == 0))
                             select new {
                                 UserID =pros.UserID,
                                 FName = pros.FName.Trim(),
                                  LName = pros.LName.Trim(),
                                  Address1 = pros.Address1.Trim(),
                                  Address2 = pros.Address2.Trim(),
                                  City = pros.City.Trim(),
                                  State = pros.State.Trim(),
                                  Country = pros.Country.Trim(),
                                  ZipCode = pros.ZipCode.Trim(),
                                  Phone1 = pros.Phone1,
                                  Phone2 = pros.Phone2,
                                  EmailID = pros.EmailID,
                                  Sex = pros.Sex,
                                  DOB = pros.DOB,
                                  Heightft = pros.Heightft,
                                  Heightin = pros.Heightin,
                                  Weight = pros.Weight,
                                  TimeStampCreated = pros.TimeStampCreated,
                                  TimeStampModified = pros.TimeStampModified,
                                  ProfileId = pros.ProfileID,
                                  TrainerID = pros.TrainerId,
                                  GymId = pros.GymID,
                                 CreatedByUser = pros.CreatedByUser ?? 0,
                                 ModifiedByUserId = pros.ModifiedByUserId ?? 0,
                                  ModifiedContext = pros.ModifiedContext ?? "",
                                 CreationNote = pros.CreationNote ?? "",
                                 ConvertedByUser = pros.ConvertedByUser??0,
                                 MemberBeforeProspect=pros.MemberBeforeProspect,
                                 IsDeleted = pros.IsDeleted,
                                 EmailOptOut = pros.EmailOptOut??false
                                  }).ToList();

                //if(GymID!=0)
                //{
                //    result = result.Where(row => row.GymID == GymID).ToList();
                //}
                if (Sort.Contains("-firstlast"))
                {
                    result = result.OrderByDescending(row => row.FName).ThenByDescending(row => row.LName).ToList();
                }
                else if (Sort.Contains("-lastfirst"))
                {
                    result = result.OrderByDescending(row => row.LName).ThenByDescending(row => row.FName).ToList();
                }
                else if (Sort.Contains("firstlast"))
                {
                    result = result.OrderBy(row => row.FName).ThenBy(row => row.LName).ToList();
                }
                else if (Sort.Contains("lastfirst"))
                {
                    result = result.OrderBy(row => row.LName).ThenBy(row => row.FName).ToList();
                }
                else if (Sort.Contains("-recent"))
                {
                    result = result.OrderBy(row => Convert.ToDateTime(row.TimeStampModified).Date).ToList();
                }
                else if (Sort.Contains("recent"))
                {
                    result = result.OrderByDescending(row => Convert.ToDateTime(row.TimeStampModified).Date).ToList();
                }

                if (StaffID > 0)
                {
                    result = result.Where(row => row.ConvertedByUser == StaffID || row.ModifiedByUserId == StaffID).ToList();
                }

                if (result.Count() > 0)
                {
                    foreach (var i in result)
                    {
                        Prospect obj = new Prospect();
                        obj.ProspectId = i.UserID;
                        obj.ProfileId = i.ProfileId ?? 0;
                        obj.GymId = int.Parse(i.GymId.ToString());
                        obj.FName = i.FName;
                        obj.LName = i.LName;
                        obj.Address1 = i.Address1 ?? "";
                        obj.Address2 = i.Address2 ?? "";
                        obj.City = i.City ?? "";
                        obj.State = i.State ?? "";
                        obj.Country = i.Country ?? "";
                        obj.ZipCode = i.ZipCode ?? "";
                        obj.Phone1 = i.Phone1 ?? "";
                        obj.Phone2 = i.Phone2 ?? "";
                        obj.Email = i.EmailID ?? "";
                        obj.Sex = i.Sex ?? "";
                        if(i.DOB!=null)
                        {
                            obj.DOB = Convert.ToDateTime(i.DOB);
                        }

                        obj.MemberBeforeProspect = i.MemberBeforeProspect;
                        obj.CreatedByUserId = i.CreatedByUser;

                        obj.CreatedContext = i.CreationNote;
                        obj.ModifiedByUserId = i.ModifiedByUserId;
                        obj.ModifiedContext = i.ModifiedContext ?? "";
                        obj.ConvertedByUserId = i.ConvertedByUser;

                        if (i.TimeStampCreated != null)
                        {
                            obj.TimeStampCreated = Convert.ToDateTime(i.TimeStampCreated);
                        }
                        if (i.TimeStampModified != null)
                        {
                            obj.TimeStampModified = Convert.ToDateTime(i.TimeStampModified);
                        }
                        obj.IsDeleted = i.IsDeleted ?? false;
                        obj.EmailOptOut = i.EmailOptOut;
                        returnvalue.Add(obj);
                    }
                }
            }
            return returnvalue;
        }
Пример #6
0
        public static Prospect ProspectDetailByProspectID(int ProspectID)
        {
            Prospect returnvalue = new Prospect();
            ProspectEntityModel context = new ProspectEntityModel();
            var result = context.AlignProspects.Where(row => row.UserID == ProspectID).ToList();
            if (result.Count() > 0)
            {
                foreach (var i in result)
                {
                    returnvalue.ProspectId = i.UserID;
                    returnvalue.ProfileId = i.ProfileID ?? 0;
                    returnvalue.GymId = int.Parse(i.GymID.ToString());
                    returnvalue.FName = i.FName;
                    returnvalue.LName = i.LName;
                    returnvalue.Address1 = i.Address1 ?? "";
                    returnvalue.Address2 = i.Address2 ?? "";
                    returnvalue.City = i.City ?? "";
                    returnvalue.State = i.State ?? "";
                    returnvalue.Country = i.Country ?? "";
                    returnvalue.ZipCode = i.ZipCode ?? "";
                    returnvalue.Phone1 = i.Phone1 ?? "";
                    returnvalue.Phone2 = i.Phone2 ?? "";
                    returnvalue.Email = i.EmailID ?? "";
                    returnvalue.Sex = i.Sex ?? "";
                    if (i.DOB != null)
                    {
                        returnvalue.DOB = Convert.ToDateTime(i.DOB);
                    }

                    returnvalue.MemberBeforeProspect = i.MemberBeforeProspect;
                    returnvalue.CreatedByUserId = i.CreatedByUser.Value;
                    returnvalue.CreatedContext = i.CreationNote;
                    returnvalue.ModifiedByUserId = i.ModifiedByUserId ??0;
                    returnvalue.ModifiedContext = i.ModifiedContext ??"";
                    returnvalue.ConvertedByUserId = i.ConvertedByUser ?? 0;
                    if (i.TimeStampCreated != null)
                    {
                        returnvalue.TimeStampCreated = Convert.ToDateTime(i.TimeStampCreated);
                    }
                    if(i.TimeStampModified!=null)
                    {
                        returnvalue.TimeStampModified = Convert.ToDateTime(i.TimeStampModified);
                    }

                    returnvalue.IsDeleted = i.IsDeleted ?? false;
                    returnvalue.EmailOptOut = i.EmailOptOut ?? false;
                }
            }
            return returnvalue;
        }