public IActionResult ChangePassword([Bind("Password,NewPassword,ReNewPassword")] ChangePasswordDetails changePasswordDetails) { try { if (ModelState.IsValid) { if (changePasswordDetails.NewPassword == changePasswordDetails.ReNewPassword) { var user = UserForChangePassword(changePasswordDetails.Password); if (user != null) { user.Password = changePasswordDetails.NewPassword; _context.Update(user); _context.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError(string.Empty, "סיסמה לא נכונה"); } } else { ModelState.AddModelError(string.Empty, "הסיסמאות שהוכנסו אינן תואמות"); } } } catch (Exception) { ModelState.AddModelError(string.Empty, "שגיאה התרחשה בעת החלפת הסיסמה"); } return(View(changePasswordDetails)); }
public IActionResult Buy(int id) { int userId = ClaimsExtension.GetUserId(HttpContext); var project = _context.Project .Include(x => x.AcademicInstitute) .Include(x => x.FieldOfStudy) .Include(x => x.Owner) .FirstOrDefault(m => m.Id == id); if (project == null) { return(NotFound()); } var user = _context.User.Find(userId); if (user == null) { return(NotFound()); } Sale sale = new Sale(); sale.Buyer = user; sale.Project = project; sale.Price = project.Price; _context.Add(sale); _context.SaveChanges(); return(View(sale)); }