public async Task <IActionResult> Create(UserManagementCreate model) { if (ModelState.IsValid) { var user = new User() { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, CreationDate = DateTime.UtcNow, }; var passwordSalt = Guid.NewGuid().ToString(); var userCredential = new UserCredential() { PasswordSalt = passwordSalt, HashedPassword = _cryptography.HashSHA256(model.Password + passwordSalt), }; user.UserCredential = userCredential; _employeeRegistration.Add(user); await _employeeRegistration.SaveChangesAsync(); ViewBag.message = "The User " + model.FirstName + " Is Saved Successfully..!"; return(RedirectToAction("Index")); } return(View(model)); }
public async Task <IActionResult> Create([Bind("Age,Attrition,BusinessTravel,DailyRate,Department,DistanceFromHome,Education,EducationField,EmployeeCount,EmployeeNumber,EnvironmentSatisfaction,Gender,HourlyRate,JobInvolvement,JobLevel,JobRole,JobSatisfaction,MaritalStatus,MonthlyIncome,MonthlyRate,NumCompaniesWorked,Over18,OverTime,PercentSalaryHike,PerformanceRating,RelationshipSatisfaction,StandardHours,StockOptionLevel,TotalWorkingYears,TrainingTimesLastYear,WorkLifeBalance,YearsAtCompany,YearsInCurrentRole,YearsSinceLastPromotion,YearsWithCurrManager")] Cmpg323Project2Dataset cmpg323Project2Dataset) { if (ModelState.IsValid) { _context.Add(cmpg323Project2Dataset); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cmpg323Project2Dataset)); }