public HttpResponseMessage UpateProfile(PersonalinfoBEL profileInfo)//, HttpPostedFileBase profilePic { string json = string.Empty; var res = new HttpResponseMessage(); JObject jContent; if (ModelState.IsValid) { try { UserDetailsDAL objUserDAL = new UserDetailsDAL(); // List<DashBoardBEL> UserMenus = objUserDAL.GetMenuMapping((((TrueWheels.Web.Models.UserLoginDetailsViewModel)(Session["userDetail"])).User_ID).ToString()); if (profileInfo.NewPassword == null) { profileInfo.NewPassword = profileInfo.Password; } //if (profileInfo.MobileNo == null) //{ // profileInfo.NewPassword = profileInfo.Password; //} UserMaintenanceViewModel objUserMaintenance = new UserMaintenanceViewModel(); objUserMaintenance.Personalinfo = objUserDAL.UpdateProfileInfo(profileInfo); objUserMaintenance.Personalinfo.profilePic_Path = objUserMaintenance.Personalinfo.User_Id + ".png"; objUserMaintenance.Personalinfo.Full_Name = objUserMaintenance.Personalinfo.First_Name + " " + objUserMaintenance.Personalinfo.Last_Name; // ViewBag.DashBoardMenu = UserMenus; if (!string.IsNullOrEmpty(objUserMaintenance.Personalinfo.ErrorMessage)) { res.StatusCode = HttpStatusCode.Unauthorized; jContent = new JObject( new JProperty("Success", false), new JProperty("result", new JObject( new JProperty("Message", "Error Occured"), new JProperty("ErrorMessage", objUserMaintenance.Personalinfo.ErrorMessage), new JProperty("UserId", "0")))); } else { json = JsonConvert.SerializeObject(objUserMaintenance); res.StatusCode = HttpStatusCode.Accepted; //res.Content = new StringContent(json); jContent = JObject.Parse(json); jContent = new JObject(new JProperty("Success", true), new JProperty("result", new JObject(JObject.Parse(json)))); } } catch (Exception ex) { res.StatusCode = HttpStatusCode.BadRequest; jContent = new JObject( new JProperty("result", new JObject( new JProperty("Success", false), new JProperty("Message", ex.Message), new JProperty("ErrorMessage", ex.InnerException.ToString()), new JProperty("Transation", null)))); } } else { var errorList = (from item in ModelState where item.Value.Errors.Any() select item.Value.Errors[0].ErrorMessage).ToList(); res.StatusCode = HttpStatusCode.BadRequest; jContent = new JObject( new JProperty("result", new JObject( new JProperty("Success", false), new JProperty("Message", "Invalid Input"), new JProperty("ErrorMessage", errorList), new JProperty("Transation", null)))); } res.Content = new StringContent(jContent.ToString()); return(res); }
public PersonalinfoBEL UpdateProfileInfo(PersonalinfoBEL personelInfo) { DataSet ds = null; PersonalinfoBEL personelInfoUpdated = new PersonalinfoBEL(); try { SqlParameter[] SqlParms = new SqlParameter[11]; SqlParms[0] = new SqlParameter("@User_id", SqlDbType.Int); SqlParms[0].Direction = ParameterDirection.Input; SqlParms[0].Value = personelInfo.User_Id; SqlParms[1] = new SqlParameter("@First_Name", SqlDbType.NVarChar, 50); SqlParms[1].Direction = ParameterDirection.Input; SqlParms[1].Value = personelInfo.First_Name; SqlParms[2] = new SqlParameter("@Last_Name", SqlDbType.NVarChar, 50); SqlParms[2].Direction = ParameterDirection.Input; SqlParms[2].Value = personelInfo.Last_Name; SqlParms[3] = new SqlParameter("@Email_id", SqlDbType.NVarChar, 500); SqlParms[3].Direction = ParameterDirection.Input; SqlParms[3].Value = personelInfo.Email_ID; SqlParms[4] = new SqlParameter("@Alternate_Email_id", SqlDbType.NVarChar, 50); SqlParms[4].Direction = ParameterDirection.Input; SqlParms[4].Value = personelInfo.Alternate_Email_Id; SqlParms[5] = new SqlParameter("@DOB", SqlDbType.DateTime); SqlParms[5].Direction = ParameterDirection.Input; SqlParms[5].Value = personelInfo.DOB; SqlParms[6] = new SqlParameter("@Phone_No2", SqlDbType.NVarChar, 50); SqlParms[6].Direction = ParameterDirection.Input; SqlParms[6].Value = personelInfo.AlternateNo; SqlParms[7] = new SqlParameter("@Driving_License", SqlDbType.NVarChar, 50); SqlParms[7].Direction = ParameterDirection.Input; SqlParms[7].Value = personelInfo.Driving_License; SqlParms[8] = new SqlParameter("@PAN", SqlDbType.NVarChar, 50); SqlParms[8].Direction = ParameterDirection.Input; SqlParms[8].Value = personelInfo.Pan_No; SqlParms[9] = new SqlParameter("@Password", SqlDbType.NVarChar, 50); SqlParms[9].Direction = ParameterDirection.Input; SqlParms[9].Value = Secure.Encrypt(personelInfo.NewPassword); SqlParms[10] = new SqlParameter("@Error", SqlDbType.NVarChar, 50); SqlParms[10].Direction = ParameterDirection.Output; ds = SqlHelper.ExecuteDataset(connectionString, CommandType.StoredProcedure, "Update_ProfileInfo", SqlParms); if (Convert.ToString(SqlParms[10].Value) == string.Empty) { personelInfoUpdated.User_Id = Convert.ToInt32(ds.Tables[0].Rows[0]["User_id"]); personelInfoUpdated.First_Name = ds.Tables[0].Rows[0]["First_Name"].ToString(); personelInfoUpdated.Last_Name = ds.Tables[0].Rows[0]["Last_Name"].ToString(); if (ds.Tables[0].Rows[0]["DOB"] != DBNull.Value) { personelInfoUpdated.DOB = Convert.ToDateTime(ds.Tables[0].Rows[0]["DOB"]); } personelInfoUpdated.Email_ID = ds.Tables[0].Rows[0]["Email_Id"].ToString(); personelInfoUpdated.Alternate_Email_Id = ds.Tables[0].Rows[0]["Alternate_Email_Id"].ToString(); personelInfoUpdated.MobileNo = ds.Tables[0].Rows[0]["Phone_No1"].ToString(); personelInfoUpdated.AlternateNo = ds.Tables[0].Rows[0]["Phone_No2"].ToString(); personelInfoUpdated.Driving_License = ds.Tables[0].Rows[0]["Driving_License"].ToString(); personelInfoUpdated.Pan_No = ds.Tables[0].Rows[0]["PAN"].ToString(); personelInfoUpdated.Owner_Address = ds.Tables[0].Rows[0]["Owner_Address"].ToString(); personelInfoUpdated.Owner_Verification_Status = Convert.ToChar(ds.Tables[0].Rows[0]["OwnerVerificationStatus"]); personelInfoUpdated.Last_Login = ds.Tables[0].Rows[0]["Last_Login"].ToString(); personelInfoUpdated.Password = Secure.Encrypt(ds.Tables[0].Rows[0]["Password"].ToString()); return(personelInfoUpdated); } else { personelInfo.Success = false; personelInfo.ErrorMessage = Convert.ToString(SqlParms[10].Value); return(personelInfo); } } catch (Exception ex) { personelInfo.Success = false; personelInfo.ErrorMessage = Convert.ToString(ex.Message.ToString()); return(personelInfo); } // return AvailableParkings; }
public HttpResponseMessage ViewProfile(string User_id) { string json = string.Empty; var res = new HttpResponseMessage(); JObject jContent; if (!string.IsNullOrEmpty(User_id)) { try { UserDetailsDAL objUserDAL = new UserDetailsDAL(); List <DashBoardBEL> UserMenus = objUserDAL.GetMenuMapping(User_id); PersonalinfoBEL objPersonalInfo = objUserDAL.GetProfileInfo(User_id); objPersonalInfo.profilePic_Path = objPersonalInfo.User_Id + ".png"; objPersonalInfo.Full_Name = objPersonalInfo.First_Name + " " + objPersonalInfo.Last_Name; objPersonalInfo.MenuList = UserMenus; if (objPersonalInfo.User_Id == 0) { res.StatusCode = HttpStatusCode.Unauthorized; jContent = new JObject( new JProperty("Success", false), new JProperty("result", new JObject( new JProperty("Message", ""), new JProperty("ErrorMessage", objPersonalInfo.ErrorMessage == null ? "" : objPersonalInfo.ErrorMessage), new JProperty("UserId", "0")))); } else { json = JsonConvert.SerializeObject(objPersonalInfo); res.StatusCode = HttpStatusCode.Accepted; //res.Content = new StringContent(json); jContent = JObject.Parse(json); jContent = new JObject(new JProperty("Success", true), new JProperty("result", new JObject(JObject.Parse(json)))); } //jContent = new JObject(res.Content); // return res; } catch (Exception ex) { res.StatusCode = HttpStatusCode.BadRequest; jContent = new JObject( new JProperty("Success", false), new JProperty("result", new JObject( new JProperty("Message", ex.Message), new JProperty("ErrorMessage", ex.InnerException.ToString()), new JProperty("UserId", null)))); // return res; } } //throw new HttpResponseException(HttpStatusCode.BadRequest); else { res.StatusCode = HttpStatusCode.Unauthorized; jContent = new JObject( new JProperty("Success", false), new JProperty("result", new JObject( new JProperty("Message", "Invalid Input"), new JProperty("ErrorMessage", "User_id is Either empty or null"), new JProperty("UserId", "0")))); // res.Content = new StringContent(jContent.ToString()); } res.Content = new StringContent(jContent.ToString()); return(res); }
//public UserDetailsBEL CheckPhoneNoExists(string Phone_No) //{ // UserDetailsBEL Userdetail = new UserDetailsBEL(); // //SqlConnection conn = new SqlConnection(); // DataSet ds = null; // try // { // SqlParameter[] SqlParms = new SqlParameter[2]; // SqlParms[0] = new SqlParameter("@Phone_No", SqlDbType.VarChar, 10); // SqlParms[0].Direction = ParameterDirection.Input; // SqlParms[0].Value = Phone_No; // SqlParms[1] = new SqlParameter("@Error", SqlDbType.VarChar, 150); // SqlParms[1].Direction = ParameterDirection.Output; // ds = SqlHelper.ExecuteDataset(connectionString, CommandType.StoredProcedure, "TW_CheckPhoneNo", SqlParms); // //&& Convert.ToString(SqlParms[5].Value) != "0" // if (Convert.ToString(SqlParms[1].Value) == string.Empty) // { // Userdetail.User_ID = ds.Tables[0].Rows[0]["User_ID"].ToString(); // Userdetail.Alternate_Email_Id = ds.Tables[0].Rows[0]["Alternate_Email_Id"].ToString(); // Userdetail.Email_Id = ds.Tables[0].Rows[0]["Email_Id"].ToString(); // Userdetail.First_Name = ds.Tables[0].Rows[0]["First_Name"].ToString(); // Userdetail.Last_Login = ds.Tables[0].Rows[0]["Last_Login"].ToString(); // Userdetail.Last_Name = ds.Tables[0].Rows[0]["Last_Name"].ToString(); // //Userdetail.Owner_Address = ds.Tables[0].Rows[0]["Owner_Address"].ToString(); // Userdetail.Phone_No1 = ds.Tables[0].Rows[0]["Phone_No1"].ToString(); // Userdetail.Phone_No2 = ds.Tables[0].Rows[0]["Phone_No2"].ToString(); // // Userdetail.SignUp_Mode_ID = ds.Tables[0].Rows[0]["SignUp_Mode_ID"].ToString(); // //Userdetail.User_Name = ds.Tables[0].Rows[0]["User_Name"].ToString(); // Userdetail.ErrorMessage = string.Empty; // Userdetail.User_Name = ds.Tables[0].Rows[0]["First_Name"].ToString() + " " + ds.Tables[0].Rows[0]["Last_Name"].ToString(); ; // // Userdetail.Last_Login = // // ResultDTO. = Convert.ToString(SqlParms[5].Value); // } // else // { // Userdetail.User_Name = ""; // Userdetail.User_ID = "0"; // Userdetail.ErrorMessage = Convert.ToString(SqlParms[4].Value); // } // } // catch (Exception ex) // { // Userdetail.User_Name = ""; // Userdetail.User_ID = "0"; // Userdetail.ErrorMessage = ex.Message.ToString(); // } // return Userdetail; //} #region UserDashboard public PersonalinfoBEL GetProfileInfo(string User_id) { PersonalinfoBEL personelInfo = new PersonalinfoBEL(); try { DataSet ds = null; SqlParameter[] SqlParms = new SqlParameter[2]; SqlParms[0] = new SqlParameter("@User_id", SqlDbType.NVarChar); SqlParms[0].Direction = ParameterDirection.Input; SqlParms[0].Value = User_id; SqlParms[1] = new SqlParameter("@Error", SqlDbType.NVarChar, 150); SqlParms[1].Direction = ParameterDirection.Output; //SqlParms[7] = new SqlParameter("@UserId", SqlDbType.NVarChar, 20); //SqlParms[7].Direction = ParameterDirection.Output; //jfhjff ds = SqlHelper.ExecuteDataset(connectionString, CommandType.StoredProcedure, "Get_ProfileInfo", SqlParms); if (Convert.ToString(SqlParms[1].Value) == string.Empty) { personelInfo.User_Id = Convert.ToInt32(ds.Tables[0].Rows[0]["User_id"]); personelInfo.First_Name = ds.Tables[0].Rows[0]["First_Name"].ToString(); personelInfo.Last_Name = ds.Tables[0].Rows[0]["Last_Name"].ToString(); if (ds.Tables[0].Rows[0]["DOB"] != DBNull.Value) { personelInfo.DOB = Convert.ToDateTime(ds.Tables[0].Rows[0]["DOB"]); } personelInfo.Email_ID = ds.Tables[0].Rows[0]["Email_Id"].ToString(); personelInfo.Alternate_Email_Id = ds.Tables[0].Rows[0]["Alternate_Email_Id"].ToString(); personelInfo.MobileNo = ds.Tables[0].Rows[0]["Phone_No1"].ToString(); personelInfo.AlternateNo = ds.Tables[0].Rows[0]["Phone_No2"].ToString(); personelInfo.Driving_License = ds.Tables[0].Rows[0]["Driving_License"].ToString(); personelInfo.Pan_No = ds.Tables[0].Rows[0]["PAN"].ToString(); personelInfo.Owner_Address = ds.Tables[0].Rows[0]["Owner_Address"].ToString(); personelInfo.Owner_Verification_Status = Convert.ToChar(ds.Tables[0].Rows[0]["OwnerVerificationStatus"]); personelInfo.Last_Login = ds.Tables[0].Rows[0]["Last_Login"].ToString(); personelInfo.Password = Secure.Decrypt(ds.Tables[0].Rows[0]["Password"].ToString()); return(personelInfo); } else { personelInfo.Success = false; personelInfo.ErrorMessage = Convert.ToString(SqlParms[1].Value); return(personelInfo); } } catch (Exception ex) { personelInfo.Success = false; personelInfo.ErrorMessage = Convert.ToString(ex.Message.ToString()); return(personelInfo); } // return AvailableParkings; }