public JsonStandardResponse Post(string userName, [FromBody] userProfileModel uProfile) { JsonStandardResponse result = null; try { DataAccessController controller = new DataAccessController(); result = new JsonStandardResponse { status = "success", data = controller.UpdateUserProfileDetails(uProfile, userName), message = "" }; } catch (Exception ex) { result = new JsonStandardResponse { status = "error", data = "", message = ex.Message }; new BusinessLogic().CreateLog(1, ex.Message, ex.HResult.ToString(), "updateUserInfo/Post"); } return(result); }
public JsonStandardResponse Post(userProfileModel uProfile) { JsonStandardResponse result = null; try { DataAccessController controller = new DataAccessController(); result = new JsonStandardResponse { status = "success", data = controller.PostUserProfileDetails(uProfile), message = "" }; } catch (Exception ex) { result = new JsonStandardResponse { status = "error", data = "", message = ex.Message }; new BusinessLogic().CreateLog(1, ex.Message, ex.HResult.ToString(), new Commons().BaseUrl + "createNewUser/Post"); } return(result); }
// GET: Product/create public ActionResult Create(int categoryID) { createProductViewModel newProduct = new Models.createProductViewModel(); newProduct.category = db.productCategory.Find(categoryID); if (newProduct.category != null) { userProfileModel userProfile = db.userprofilemodel.Find(User.Identity.GetUserId()); if (userProfile != null) { newProduct.sellerID = userProfile.ID; newProduct.seller = db.Users.Find(userProfile.UserID); newProduct.unitList = new List <SelectListItem>(); foreach (var unit in db.unitsModel.ToList()) { newProduct.unitList.Add(new SelectListItem { Text = unit.unitAbvr, Value = unit.ID.ToString() }); } } return(View("Create", newProduct)); } else { return(RedirectToAction("createProductStepOne")); } }
public string createUsernamePrefix(userProfileModel model) { char fNameInitial = model.fName.ElementAt(0); string newUN = model.lName + "." + fNameInitial; return(newUN); }
public ActionResult manageProfile() { var userId = User.Identity.GetUserId(); userProfileModel model = new userProfileModel(); model = db.userprofilemodel.Find(userId); return(View(model)); }
public ActionResult manageProfile(userProfileModel model) { if (ModelState.IsValid) { db.Entry(model).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Home")); } else { return(View(model)); } }
// POST: UserEmergencies/getUser //Get a single user profile. public Users getUser(UserEmergency theProfile) { Users result = new Users(); result.phone = theProfile.EmergencyContactPhone; UserProfile thisUser = db.UserProfile.Find(theProfile.UserProfileId); userProfileModel theUser = new userProfileModel(); theUser.id = thisUser.Id; theUser.address = thisUser.Address; theUser.FirstName = thisUser.FirstName; theUser.LastName = thisUser.LastName; theUser.Gender = thisUser.Gender; result.userDetails = theUser; return(result); }
public async Task <ActionResult> Register(newUserViewModel model) { string username = ""; if (ModelState.IsValid) { if (model.newProfile.user.UserName != null) { string checkedUsername = createUserName(model.newProfile.user.UserName); if (checkedUsername == model.newProfile.user.UserName) { username = model.newProfile.user.UserName; } else { ViewBag.ErrorMessage = "Username is already in use, try something else or leave line blank to use your email address."; return(View(model)); } } else { username = createUserName(createUsernamePrefix(model.newProfile)); } ApplicationUser user = new ApplicationUser { UserName = username, Email = model.newUser.Email }; var result = await UserManager.CreateAsync(user, model.newUser.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); UserManager.AddToRole(user.Id, "StdUser"); var profile = new userProfileModel { fName = model.newProfile.fName, MInitial = model.newProfile.MInitial, lName = model.newProfile.lName, state = model.newProfile.state, city = model.newProfile.city, zipcode = model.newProfile.zipcode, address = model.newProfile.address, contactEmail = model.newUser.Email, ID = user.Id, UserID = user.Id }; db.userprofilemodel.Add(profile); db.SaveChanges(); await signInOut(model.newUser.Password, user); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public DataTable UpdateUserProfileDetails(userProfileModel userProfileObj, string userName) { DataTable result = null; SqlConnection connection = null; try { connection = GetSQLConnection(); SqlCommand command = new SqlCommand("sp_UPDATE_USER", connection); command.CommandType = System.Data.CommandType.StoredProcedure; if (userProfileObj.username == null) { userProfileObj.username = string.Empty; } if (userProfileObj.fullName == null) { userProfileObj.fullName = string.Empty; } if (userProfileObj.emiratesID == null) { userProfileObj.emiratesID = string.Empty; } if (userProfileObj.licenseNo == null) { userProfileObj.licenseNo = string.Empty; } if (userProfileObj.emailAddr == null) { userProfileObj.emailAddr = string.Empty; } if (userProfileObj.AddrHome == null) { userProfileObj.AddrHome = string.Empty; } if (userProfileObj.pictureUrl == null) { userProfileObj.pictureUrl = string.Empty; } if (userProfileObj.phoneNo == null) { userProfileObj.phoneNo = string.Empty; } command.Parameters.AddWithValue("@user", userName); command.Parameters.AddWithValue("@username", userProfileObj.username); command.Parameters.AddWithValue("@fullName", userProfileObj.fullName); command.Parameters.AddWithValue("@emirateID", userProfileObj.emiratesID); command.Parameters.AddWithValue("@licenseNo", userProfileObj.licenseNo); command.Parameters.AddWithValue("@emailAddr", userProfileObj.emailAddr); command.Parameters.AddWithValue("@AddrHome", userProfileObj.AddrHome); command.Parameters.AddWithValue("@status", userProfileObj.userActStatus); command.Parameters.AddWithValue("@pictureUrl", userProfileObj.pictureUrl); command.Parameters.AddWithValue("@phoneNo", userProfileObj.phoneNo); // command.Parameters.AddWithValue("@picture", userProfileObj.picture); int returnValue = command.ExecuteNonQuery(); if (returnValue > 0) { result = GetSingleUserDetails(userProfileObj.username.ToString()); } } catch (Exception ex) { new BusinessLogic().CreateLog(1, ex.Message, ex.HResult.ToString(), "UpdateUserProfileDetails function in DataAccess Controller Class"); throw ex; } finally { if (connection.State == ConnectionState.Open) { connection.Close(); } } return(result); }