public string Enroll(Stream message) { try { Enrollment objInput = JSonHelper.JsonDeserialize<Enrollment>(new StreamReader(message).ReadToEnd()); if (System.Configuration.ConfigurationManager.AppSettings[objInput.Pin] == null) { return "Invalid PIN"; } if (objInput.Pin != null && objInput.Pin.Length > 0) { UserBLL oUser1 = new UserBLL(); UserInfo _UserInfo1 = new UserInfo(); System.Data.DataSet ds = new System.Data.DataSet(); _UserInfo1.PracticeTin = objInput.PracticeTin; _UserInfo1.PracticeName = objInput.PracticeName; _UserInfo1.pin = System.Configuration.ConfigurationManager.AppSettings[objInput.Pin].ToString(); ds = oUser1.getpracticename1(objInput.PracticeTin); int iPracticeID = 0; int iLocationID = 0; if (ds.Tables[0].Rows.Count > 0) { iPracticeID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProviderId"].ToString()); System.Data.DataSet dslocation = oUser1.getLocationDetails(objInput.PracticeTin); iLocationID = Convert.ToInt32(dslocation.Tables[0].Rows[0]["LocationId"].ToString()); } else { int i = oUser1.insertPractice(_UserInfo1); if (i > 0) { ds = oUser1.getpracticename1(objInput.PracticeTin); if (ds.Tables[0].Rows.Count > 0) { iPracticeID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProviderId"].ToString()); System.Data.DataSet dslocation = oUser1.getLocationDetails(objInput.PracticeTin); if (dslocation.Tables[0].Rows.Count <= 0) { _UserInfo1.LocationName = objInput.LocationName; _UserInfo1.OrganisationName = objInput.OrganizationType; _UserInfo1.practicephone = objInput.PracticePhone; _UserInfo1.PracticeAddress = objInput.Address; _UserInfo1.practiceFax = objInput.PracticeFax; _UserInfo1.PracticeCity = objInput.City; _UserInfo1.PracticeState = objInput.State; _UserInfo1.PracticeZip = objInput.State; _UserInfo1.ProviderId = Convert.ToInt32(ds.Tables[0].Rows[0]["ProviderId"].ToString()); int j = oUser1.insertLocationDetails(_UserInfo1); dslocation = oUser1.getLocationDetails(objInput.PracticeTin); iLocationID = Convert.ToInt32(dslocation.Tables[0].Rows[0]["LocationId"].ToString()); } else { iLocationID = Convert.ToInt32(ds.Tables[0].Rows[0]["LocationId"].ToString()); } } } } if (iPracticeID > 0 && iLocationID > 0) { _UserInfo1.PhysicianId = 0; _UserInfo1.ProviderId = iPracticeID; _UserInfo1.PhyOfficeName = objInput.PracticeName; _UserInfo1.fname = objInput.FirstName; _UserInfo1.lname = objInput.LastName; _UserInfo1.UserType = 2; _UserInfo1.UserRole = 2; _UserInfo1.EmailId = objInput.EmailAddress; _UserInfo1.Password = objInput.Password; _UserInfo1.EmailAddress = objInput.EmailAddress; _UserInfo1.DirectEmail = ""; _UserInfo1.practicephone = objInput.PracticePhone; _UserInfo1.LocationIds = iLocationID.ToString(); _UserInfo1.SecurityQuestion1 = objInput.SecurityQuestion1; _UserInfo1.SecurityQuestion2 = objInput.SecurityQuestion2; _UserInfo1.SecurityQuestion3 = objInput.SecurityQuestion3; _UserInfo1.SecurityAnswer1 = objInput.SecurityAnswer1; _UserInfo1.SecurityAnswer2 = objInput.SecurityAnswer2; _UserInfo1.SecurityAnswer3 = objInput.SecurityAnswer3; UserInfo info1 = oUser1.getUserDetailsByEmailId(objInput.EmailAddress, _UserInfo1.pin); if (info1.UserId > 0) { return "User already exists"; } else { int success = oUser1.insertuserfromEnrollment(_UserInfo1); return "Enrollment Sucessful"; } } return "Unable to enroll. please try again later"; } else { return "Pin is a required field"; } } catch (Exception ex) { return ex.Message; } }