public AllPersonalInformation GetPersonInformation(int id) { AllPersonalInformation person = new AllPersonalInformation(); GenarateConnection(); string query = "SELECT * FROM Person WHERE ID =@SignupID"; Command = new SqlCommand(query, Connection); Command.Parameters.Clear(); Command.Parameters.Add("@SignupID", SqlDbType.VarChar); Command.Parameters["@SignupID"].Value = id; Connection.Open(); Reader = Command.ExecuteReader(); Reader.Read(); if (Reader.HasRows) { person.AdditionalInfoID = Convert.ToInt32(Reader["ID"].ToString()); person.Name = Reader["Name"].ToString(); person.Email = Reader["Email"].ToString(); person.Password = Reader["Password"].ToString(); person.ConfirmPassword = Reader["Password"].ToString(); person.MobileNumber = Reader["MobileNo"].ToString(); person.DateOfBirth = Reader["DateOfBirth"].ToString(); person.Gender = Convert.ToInt32(Reader["Gender"].ToString()); person.AdditionalInfoID = Convert.ToInt32(Reader["ProfileID"].ToString()); } Connection.Close(); return(person); }
public AllPersonalInformation GetAdditionInformation(int id) { AllPersonalInformation person = new AllPersonalInformation(); GenarateConnection(); string query = "SELECT * FROM PersonalInformation WHERE SignupID =@ID"; Command = new SqlCommand(query, Connection); Command.Parameters.Clear(); Command.Parameters.Add("@ID", SqlDbType.VarChar); Command.Parameters["@ID"].Value = id; Connection.Open(); Reader = Command.ExecuteReader(); Reader.Read(); if (Reader.HasRows) { person.AdditionalInfoID = Convert.ToInt32(Reader["ID"].ToString()); person.ProfilePhotoId = Convert.ToInt32(Reader["ProfilePhoto"].ToString()); person.CoverPhotoId = Convert.ToInt32(Reader["CoverPhoto"].ToString()); person.AboutMe = Reader["AboutMe"].ToString(); person.Religion = Reader["Religion"].ToString(); person.EducationID = Convert.ToInt32(Reader["EducationID"].ToString()); person.JobID = Convert.ToInt32(Reader["JobID"].ToString()); person.AreaOfInterest = Reader["AreaOfInterest"].ToString(); person.Address = Reader["Address"].ToString(); } Connection.Close(); return(person); }
public ActionResult EditView(int signupIds) { Authentication authentication = (Authentication)Session["authentication"]; if (authentication == null) { TempData["msg"] = "<script>alert('Please Log in First');</script>"; return(RedirectToAction("SignUpView", "SignUp")); } Person person = homeManager.GetPersonInformation(signupIds); if (person == null) { TempData["msg"] = "<script>alert('Please Log in First');</script>"; return(RedirectToAction("SignUpView", "SignUp")); } if (person.Password.Equals(authentication.Password)) { ViewBag.SignupID = authentication.Id; ViewBag.Password = authentication.Password; ViewBag.Name = authentication.Name; AllPersonalInformation allPersonalInformation = editManager.GetAdditionInformation(signupIds); ViewBag.AdditionalInfoID = allPersonalInformation.AdditionalInfoID; ViewBag.ProfilePhotoId = allPersonalInformation.ProfilePhotoId; ViewBag.CoverPhotoId = allPersonalInformation.CoverPhotoId; allPersonalInformation = editManager.GetAllPersonalInformation(authentication.Id); ViewBag.NotificationList = homeManager.GetAllNotification(authentication.Id); return(View(allPersonalInformation)); } else { TempData["msg"] = "<script>alert('Please Log in First');</script>"; return(RedirectToAction("SignUpView", "SignUp")); } }
public bool UpdateAllInformation(AllPersonalInformation allPersonalInformation) { bool result = false; if (allPersonalInformation.PhotoInByte != null) { if (!SetProfilePhoto(allPersonalInformation)) { return(result); } allPersonalInformation.ProfilePhotoId = GetProfilePhotoID(allPersonalInformation.SignupID); } if (allPersonalInformation.CoverPhotoInByte != null) { if (!SetCoverPhoto(allPersonalInformation)) { return(result); } allPersonalInformation.CoverPhotoId = GetCoverPhotoID(allPersonalInformation.SignupID); } if (!UpdatePersonInformation(allPersonalInformation)) { return(result); } if (!UpdateAdditionalInformation(allPersonalInformation)) { return(result); } result = true; return(result); }
public bool SetCoverPhoto(AllPersonalInformation allPersonalInformation) { Photo photo = new Photo(); photo.PhotoInByte = allPersonalInformation.CoverPhotoInByte; photo.SignupID = allPersonalInformation.SignupID; return(signUpGateway.SetCoverPhoto(photo)); }
public bool UpdateAdditionalInformation(AllPersonalInformation allPersonalInformation) { GenarateConnection(); using (Connection) { Connection.Open(); string query = "UPDATE PersonalInformation SET ProfilePhoto=@ProfilePhoto,CoverPhoto=@CoverPhoto,AboutMe=@AboutMe,Religion=@Religion,EducationID=@EducationID,JobID=@JobID,AreaOfInterest=@AreaOfInterest,Address=@Address WHERE SignupID=@SignupID;"; Command = new SqlCommand(query, Connection); Command.Parameters.Clear(); Command.Parameters.Add("@SignupID", SqlDbType.Int); Command.Parameters["@SignupID"].Value = allPersonalInformation.SignupID; Command.Parameters.Add("@ProfilePhoto", SqlDbType.Int); Command.Parameters["@ProfilePhoto"].Value = allPersonalInformation.ProfilePhotoId; Command.Parameters.Add("@CoverPhoto", SqlDbType.Int); Command.Parameters["@CoverPhoto"].Value = allPersonalInformation.CoverPhotoId; Command.Parameters.Add("@AboutMe", SqlDbType.VarChar); Command.Parameters["@AboutMe"].Value = allPersonalInformation.AboutMe; Command.Parameters.Add("@Religion", SqlDbType.VarChar); Command.Parameters["@Religion"].Value = allPersonalInformation.Religion; Command.Parameters.Add("@EducationID", SqlDbType.Int); Command.Parameters["@EducationID"].Value = allPersonalInformation.EducationID; Command.Parameters.Add("@JobID", SqlDbType.Int); Command.Parameters["@JobID"].Value = allPersonalInformation.JobID; Command.Parameters.Add("@AreaOfInterest", SqlDbType.VarChar); Command.Parameters["@AreaOfInterest"].Value = allPersonalInformation.AreaOfInterest; Command.Parameters.Add("@Address", SqlDbType.VarChar); Command.Parameters["@Address"].Value = allPersonalInformation.Address; try { Command.ExecuteNonQuery(); Connection.Close(); return(true); } catch (Exception) { throw new Exception("Error While Entering data into database"); } } }
public AllPersonalInformation GetAllPersonalInformation(int id) { AllPersonalInformation allPersonalInformation = new AllPersonalInformation(); AllPersonalInformation personal = GetPersonInformation(id); AllPersonalInformation addition = GetAdditionInformation(id); Photo profilePhoto = GetProfilePhotoByID(addition.ProfilePhotoId); Photo coverPhoto = GetCoverPhotoByID(addition.CoverPhotoId); allPersonalInformation.SignupID = id; allPersonalInformation.AdditionalInfoID = addition.AdditionalInfoID; allPersonalInformation.Password = personal.Password; allPersonalInformation.Email = personal.Email; allPersonalInformation.ProfilePhotoId = addition.ProfilePhotoId; if (allPersonalInformation.ProfilePhotoId != 0) { allPersonalInformation.ProfilePhotoInString = profilePhoto.PhotoInString; allPersonalInformation.PhotoInByte = profilePhoto.PhotoInByte; } allPersonalInformation.CoverPhotoId = addition.CoverPhotoId; if (allPersonalInformation.CoverPhotoId != 0) { allPersonalInformation.CoverPhotoInString = coverPhoto.PhotoInString; allPersonalInformation.CoverPhotoInByte = coverPhoto.PhotoInByte; } allPersonalInformation.Name = personal.Name; allPersonalInformation.OldPassword = null; allPersonalInformation.NewPassword = null; allPersonalInformation.ConfirmPassword = null; allPersonalInformation.AboutMe = addition.AboutMe; allPersonalInformation.AreaOfInterest = addition.AreaOfInterest; allPersonalInformation.MobileNumber = personal.MobileNumber; allPersonalInformation.Religion = addition.Religion; allPersonalInformation.Address = addition.Address; allPersonalInformation.DateOfBirth = personal.DateOfBirth; allPersonalInformation.Gender = personal.Gender; return(allPersonalInformation); }
public bool UpdatePersonInformation(AllPersonalInformation allPersonalInformation) { GenarateConnection(); using (Connection) { Connection.Open(); string query = "UPDATE Person SET Name=@Name,MobileNo=@MobileNo,Password=@Password,DateOfBirth=@DateOfBirth,Gender=@Gender WHERE ID=@ID;"; Command = new SqlCommand(query, Connection); Command.Parameters.Clear(); Command.Parameters.Add("@ID", SqlDbType.Int); Command.Parameters["@ID"].Value = allPersonalInformation.SignupID; Command.Parameters.Add("@Name", SqlDbType.VarChar); Command.Parameters["@Name"].Value = allPersonalInformation.Name; Command.Parameters.Add("@MobileNo", SqlDbType.VarChar); Command.Parameters["@MobileNo"].Value = allPersonalInformation.MobileNumber; Command.Parameters.Add("@Password", SqlDbType.VarChar); Command.Parameters["@Password"].Value = allPersonalInformation.NewPassword; Command.Parameters.Add("@DateOfBirth", SqlDbType.VarChar); Command.Parameters["@DateOfBirth"].Value = allPersonalInformation.DateOfBirth; Command.Parameters.Add("@Gender", SqlDbType.Int); Command.Parameters["@Gender"].Value = allPersonalInformation.Gender; try { Command.ExecuteNonQuery(); Connection.Close(); return(true); } catch (Exception) { throw new Exception("Error While Entering data into database"); } } }
public ActionResult EditView(AllPersonalInformation allPersonalInformation) { Authentication authentication = (Authentication)Session["authentication"]; if (authentication == null) { TempData["msg"] = "<script>alert('Please Log in First');</script>"; return(RedirectToAction("SignUpView", "SignUp")); } ViewBag.SignupID = authentication.Id; ViewBag.Password = authentication.Password; ViewBag.Name = authentication.Name; ViewBag.NotificationList = homeManager.GetAllNotification(authentication.Id); if (!ModelState.IsValid) { return(View(allPersonalInformation)); } HttpPostedFileBase file = allPersonalInformation.ProfilePhoto; if (file != null) { string fileName = Path.GetFileName(file.FileName); string fileExtension = Path.GetExtension(fileName); int fileSize = file.ContentLength; if (fileExtension.ToLower() == ".jpg" || fileExtension.ToLower() == ".bmp" || fileExtension.ToLower() == ".gif" || fileExtension.ToLower() == ".png") { Stream stream = file.InputStream; BinaryReader binaryReader = new BinaryReader(stream); byte[] bytes = binaryReader.ReadBytes((int)stream.Length); allPersonalInformation.PhotoInByte = bytes; } else { ViewBag.ErrorMessage = "Only images (.jpg, .png, .gif and .bmp) can be uploaded"; return(View(allPersonalInformation)); } } else { allPersonalInformation.ProfilePhotoId = 3; } HttpPostedFileBase files = allPersonalInformation.CoverPhoto; if (files != null) { string fileNames = Path.GetFileName(files.FileName); string fileExtensions = Path.GetExtension(fileNames); int fileSizes = files.ContentLength; if (fileExtensions.ToLower() == ".jpg" || fileExtensions.ToLower() == ".bmp" || fileExtensions.ToLower() == ".gif" || fileExtensions.ToLower() == ".png") { Stream streams = files.InputStream; BinaryReader binaryReaders = new BinaryReader(streams); byte[] bytess = binaryReaders.ReadBytes((int)streams.Length); allPersonalInformation.CoverPhotoInByte = bytess; } else { ViewBag.ErrorMessage = "Only images (.jpg, .png, .gif and .bmp) can be uploaded"; return(View(allPersonalInformation)); } } else { allPersonalInformation.CoverPhotoId = 3; } if (allPersonalInformation.AboutMe == null) { allPersonalInformation.AboutMe = "."; } if (allPersonalInformation.Religion == null) { allPersonalInformation.Religion = "."; } if (allPersonalInformation.MobileNumber == null) { allPersonalInformation.MobileNumber = "."; } if (allPersonalInformation.AreaOfInterest == null) { allPersonalInformation.AreaOfInterest = "."; } if (allPersonalInformation.Address == null) { allPersonalInformation.Address = "."; } if (allPersonalInformation.OldPassword != authentication.Password) { ViewBag.ErrorMessage = "Given Password do not match with old password"; return(View(allPersonalInformation)); } if (allPersonalInformation.NewPassword == null) { allPersonalInformation.NewPassword = authentication.Password; } if (editManager.UpdateAllInformation(allPersonalInformation)) { ViewBag.SuccesMessage = "All new information updated successfully"; return(View(allPersonalInformation)); } ViewBag.ErrorMessage = "All new information updated failed"; return(View(allPersonalInformation)); }
public bool UpdateAdditionalInformation(AllPersonalInformation allPersonalInformation) { return(editGateway.UpdateAdditionalInformation(allPersonalInformation)); }