public JsonResult GetProfiletByID(int catID) { UserProfileEntity ProjectDetails = null; try { var objDtl = new ProfileComponent(); ProjectDetails = objDtl.GetProfileDetailByID(catID); } catch (Exception ex) { return(null); } return(Json(ProjectDetails, JsonRequestBehavior.AllowGet)); }
public string UpdateProfile(UserProfileEntity user) { UsersProfile userData = null; //string ImageName = System.IO.Path.GetFileName(file.FileName); UserSessionInfo objSessioninfo = new UserSessionInfo(); string strResponse = string.Empty; short UsTCurrentVersion = 0; string imagename = string.Empty; if (Request.Files.Count > 0) { var file = Request.Files[0]; var fileName = "/uploadimages/Images/" + file.FileName; imagename = file.FileName; var imagepath = Server.MapPath(fileName); file.SaveAs(imagepath); user.Usrp_ProfilePicture = imagename; try { var ProjectComponent = new ProfileComponent(); var currentProjectDetails = ProjectComponent.GetProfileDetailid(user.UsrP_UserID); int ProjectID = currentProjectDetails.UsrP_UserProfileID; UsTCurrentVersion = Convert.ToInt16(currentProjectDetails.UsrP_Version); // bool _currentStatus = false; //check for version and active status //if (ModelState["UsrP_ActiveStatus"].Value == null) //{ // _currentStatus = user.UsrP_ActiveStatus == true; //} if (ModelState.IsValid) { UserSessionInfo _objSessioninfo = Session["UserSessionInfo"] as UserSessionInfo; int _userID = _objSessioninfo.UserId; user.UsrP_ModifiedBy = _userID; //while udating increment version by1 user.UsrP_Version = ++UsTCurrentVersion; user.UsrP_ActiveStatus = true; user.UsrP_UserProfileID = ProjectID; var Org = new ProfileComponent(); int r = Org.UpdateProfileDetail(user); if (r > 0) { strResponse = "Profile updated successfully"; objSessioninfo.Usrp_ProfilePicture = imagename; } else if (r == 0) { strResponse = "Profile does not exists"; } else if (r < 0) { strResponse = "Error occured in UpdateProject"; } } } catch (Exception ex) { ex.Message.ToString(); } } else { using (var db = new EvolutyzCornerDataEntities()) { try { userData = db.Set <UsersProfile>().Where(s => s.UsrP_UserID == user.UsrP_UserID).FirstOrDefault <UsersProfile>(); if (userData != null) { var ProjectComponent = new ProfileComponent(); var currentProjectDetails = ProjectComponent.GetProfileDetailByID(user.UsrP_UserID); int ProjectID = currentProjectDetails.UsrP_UserProfileID; UsTCurrentVersion = Convert.ToInt16(currentProjectDetails.UsrP_Version); // bool _currentStatus = false; //check for version and active status //if (ModelState["UsrP_ActiveStatus"].Value == null) //{ // _currentStatus = user.UsrP_ActiveStatus == true; //} if (ModelState.IsValid) { UserSessionInfo _objSessioninfo = Session["UserSessionInfo"] as UserSessionInfo; int _userID = _objSessioninfo.UserId; user.UsrP_ModifiedBy = _userID; //while udating increment version by1 user.UsrP_Version = ++UsTCurrentVersion; user.UsrP_ActiveStatus = true; var Org = new ProfileComponent(); int r = Org.UpdateProfileDetailByImage(user); if (r > 0) { strResponse = "Profile updated successfully"; } else if (r == 0) { strResponse = "Profile does not exists"; } else if (r < 0) { strResponse = "Error occured in UpdateProject"; } } } else { //int retVal = 0; UsersProfile profilesave = new UsersProfile(); try { //Project = db.Set<Project>().Where(s => s.Proj_ProjectID == _project.Proj_ProjectID).FirstOrDefault<Project>(); #region Saving ProjectAllocation info Table profilesave.UsrP_UserID = user.UsrP_UserID; profilesave.UsrP_FirstName = user.UsrP_FirstName; profilesave.UsrP_LastName = user.UsrP_LastName; profilesave.Usrp_ProfilePicture = user.Usrp_ProfilePicture; profilesave.Usrp_DOJ = user.Usrp_DOJ; profilesave.UsrP_DOB = user.UsrP_DOB; profilesave.Usrp_MobileNumber = user.Usrp_MobileNumber; profilesave.UsrP_EmailID = user.UsrP_EmailID; profilesave.TemporaryAddress = user.TemporaryAddress; profilesave.PermanentAddress = user.PermanentAddress; profilesave.UsrP_ActiveStatus = user.UsrP_ActiveStatus; profilesave.UsrP_Version = user.UsrP_Version; profilesave.UsrP_CreatedDate = System.DateTime.Now; profilesave.UsrP_CreatedBy = user.UsrP_CreatedBy; profilesave.UsrP_ModifiedDate = System.DateTime.Now; profilesave.UsrP_ModifiedBy = user.UsrP_ModifiedBy; profilesave.UsrP_isDeleted = user.UsrP_isDeleted; profilesave.Marital_Status = user.Marital_Status; profilesave.Usr_GenderId = user.Usr_GenderId; profilesave.Usr_Titleid = user.Usr_Titleid; profilesave.UsrP_EmployeeID = user.UsrP_EmployeeID; profilesave.Usrp_MobileNumber = user.Usrp_PhoneNumber; #endregion // db.UsersProfiles.up(profilesave); db.Entry(profilesave).State = EntityState.Added; // db.Entry(profilesave).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } catch (Exception ex) { //retVal = -1; } } } catch (Exception ex) { ex.Message.ToString(); } } } return(strResponse); }