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; }
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; }
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; }