public User(UserApi u) { if (u != null) { Id = u.Id; UserName = u.UserName; Password = u.Password; FirstName = u.FirstName; LastName = u.LastName; Email = u.Email; Admin = u.Admin; Ban = u.Ban; Rating = u.Rating; Phone = u.Phone; ReportId = u.ReportId; ActiveCode = u.ActiveCode; ResetPassword = u.ResetPassword; DateRequest = u.DateRequest; BanDate = u.BanDate; BanTime = u.BanTime; UserImage = u.UserImage; } Comments = new HashSet<Comment>(); FollowProducts = new HashSet<FollowProduct>(); SentMessages = new HashSet<Message>(); ReceivedMessages = new HashSet<Message>(); Products = new HashSet<Product>(); Reports = new HashSet<Report>(); Reports1 = new HashSet<Report>(); VoteLogs = new HashSet<VoteLog>(); }
public ActionResult UpdateUserInfo() { if (Request.Form.Count > 0) { UserApi updatedUserInfo = new UserApi(); updatedUserInfo.FirstName = Request.Form["FirstName"]; updatedUserInfo.LastName = Request.Form["LastName"]; updatedUserInfo.Email = Request.Form["email"]; updatedUserInfo.Phone = Request.Form["PhoneNumber"]; updatedUserInfo.Password = Request.Form["CurrentPassword"]; string newPassword = Request.Form["NewPassword"]; string newPasswordConfirm = Request.Form["NewPassword_confirm"]; if (updatedUserInfo.Password != null && updatedUserInfo.Password != newPassword && newPassword != null && newPasswordConfirm != null && newPassword == newPasswordConfirm) { if (WebApiHelper.CheckInvalidPassword("api/accountManager/account/checkInvalidPassword", Method.POST, (int)Session["UserId"], updatedUserInfo.Password)) { updatedUserInfo.Password = newPassword; } } updatedUserInfo.Id = (int) Session["UserId"]; WebApiHelper.UpdateUserInfo("api/accountManager/account/update", Method.POST, updatedUserInfo); } return RedirectToAction("DisplayUserInfo", "Account"); }
public static bool RegisterAccount(string requestResource, Method method, UserApi newUser) { var client = new RestClient(); // This, of course, needs to be altered to match the // IP Address/Port of the server to which you are connecting client.BaseUrl = new Uri(ClientBase); var request = new RestRequest(); // The server's Rest method will probably return something // other than "duckbilledPlatypi" in your case request.Resource = requestResource + "/" + newUser.UserName + Seperator + newUser.Password + Seperator + " " + Seperator + newUser.LastName + Seperator + newUser.FirstName + Seperator + newUser.Phone + "?email=" + newUser.Email; request.Method = method; var response = client.Execute(request) as RestResponse; if (response != null && ((response.StatusCode == HttpStatusCode.OK) && (response.ResponseStatus == ResponseStatus.Completed))) // It's probably not necessary to test both { return true; } else if (response != null) { return false; } return false; }