public HttpResponseMessage UserUpdateProfile(UserUpdateModelRequest objUserUpdateModelRequest) { FResponse result = new FResponse(); try { var headers = Request.Headers; string token = headers.Authorization.Parameter.ToString(); Int64 UserId = _objFriendFitDBEntity.Database.SqlQuery <Int64>("select UserId from UserToken where TokenCode={0}", token).FirstOrDefault(); var model = _objIUserSettings.UpdateUser(objUserUpdateModelRequest, UserId); if (model > 0) { result.StatusCode = Convert.ToInt32(HttpStatusCode.OK); result.Message = "Your profile updated successfully!!"; } else { result.StatusCode = Convert.ToInt32(HttpStatusCode.NotFound); result.Message = "Data is invalid!!"; } } catch (Exception ex) { _response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Some error occurred"); } _response = Request.CreateResponse(HttpStatusCode.OK, result); return(_response); }
public int UpdateUser(UserUpdateModelRequest objUserUpdateModelRequest, Int64 UserId) { objUserUpdateModelRequest.Password = CryptorEngine.Encrypt(objUserUpdateModelRequest.Password, true); int rowEffected; if (objUserUpdateModelRequest.AutoSMSSignUp == null) { rowEffected = _objFriendFitDBEntity.Database.ExecuteSqlCommand("UpdateUser @UserId=@UserId,@FirstName=@FirstName,@LastName=@LastName,@Email=@Email,@Password=@Password,@MobileNumber=@MobileNumber,@CountryId=@CountryId,@AutoSMSSignUp=@AutoSMSSignUp,@FullWorkoutStatus=@FullWorkoutStatus,@WorkoutStatus=@WorkoutStatus", new SqlParameter("UserId", UserId), new SqlParameter("FirstName", objUserUpdateModelRequest.FirstName), new SqlParameter("LastName", objUserUpdateModelRequest.LastName), new SqlParameter("Email", objUserUpdateModelRequest.Email), new SqlParameter("Password", (Object)objUserUpdateModelRequest.Password ?? DBNull.Value), new SqlParameter("MobileNumber", objUserUpdateModelRequest.MobileNumber), new SqlParameter("CountryId", objUserUpdateModelRequest.CountryId), new SqlParameter("AutoSMSSignUp", false), new SqlParameter("FullWorkoutStatus", objUserUpdateModelRequest.FullWorkoutStatus), new SqlParameter("WorkoutStatus", objUserUpdateModelRequest.WorkoutStatus)); } else { rowEffected = _objFriendFitDBEntity.Database.ExecuteSqlCommand("UpdateUser @UserId=@UserId,@FirstName=@FirstName,@LastName=@LastName,@Email=@Email,@Password=@Password,@MobileNumber=@MobileNumber,@CountryId=@CountryId,@AutoSMSSignUp=@AutoSMSSignUp,@FullWorkoutStatus=@FullWorkoutStatus,@WorkoutStatus=@WorkoutStatus", new SqlParameter("UserId", UserId), new SqlParameter("FirstName", objUserUpdateModelRequest.FirstName), new SqlParameter("LastName", objUserUpdateModelRequest.LastName), new SqlParameter("Email", objUserUpdateModelRequest.Email), new SqlParameter("Password", (Object)objUserUpdateModelRequest.Password ?? DBNull.Value), new SqlParameter("MobileNumber", objUserUpdateModelRequest.MobileNumber), new SqlParameter("CountryId", objUserUpdateModelRequest.CountryId), new SqlParameter("AutoSMSSignUp", objUserUpdateModelRequest.AutoSMSSignUp), new SqlParameter("FullWorkoutStatus", objUserUpdateModelRequest.FullWorkoutStatus), new SqlParameter("WorkoutStatus", objUserUpdateModelRequest.WorkoutStatus)); } return(rowEffected); }