public BaseResponse updateUser(UpdateUserReqObj updatedUserObj) { BaseResponse res = new BaseResponse(); try { var db = _db; var obj = db.User.SingleOrDefault(b => b.Id == updatedUserObj.UserId); if (obj != null) { obj.Phone = updatedUserObj.phone; obj.Email = updatedUserObj.email; res.status = db.SaveChanges(); } if (res.status == 1) { res.developerMessage = res.developerMessage + "Profile Updated Successfully"; } else { res.status = -2; res.developerMessage = res.developerMessage + "Profile Didn't Update, Try Again Later"; } } catch (Exception e) { res.status = -1; res.developerMessage = res.developerMessage + "Something went wrong: " + e.Message; } return(res); }
public BaseResponse updateUser(UpdateUserReqObj updatedUserObj) { BaseResponse res = new BaseResponse(); try { var db = _db; var obj = db.Users.Include(m => m.ProfileImage).SingleOrDefault(b => b.Id == updatedUserObj.userID); if (obj != null) { obj.Phone = updatedUserObj.phone; obj.Name = updatedUserObj.name; obj.Address = updatedUserObj.address; // Updat the image only when not null and not empty. // if(updatedUserObj.image != null && updatedUserObj.image.Trim() != "") obj.ProfileImage.Data = Encoding.UTF8.GetBytes(updatedUserObj.image); res.status = db.SaveChanges(); } res.status = 1; res.developerMessage = res.developerMessage + "Profile Updated Successfully"; // if (res.status > 0) // { // } // else // { // // res.status = -2; // res.developerMessage = res.developerMessage + "Profile Didn't Update, Try Again Later" + res.status; // } } catch (Exception e) { res.status = -1; res.developerMessage = res.developerMessage + "Something went wrong: " + e.Message; } return(res); }
public BaseResponse UpdateUser([FromBody] UpdateUserReqObj updatedUserObj) { return(new UserService(_db).updateUser(updatedUserObj)); }
public BaseResponse UpdateUser([FromBody] UpdateUserReqObj updatedUserObj) { return(new BLL.BLL_Users(_db).updateUser(updatedUserObj)); }