public IActionResult Save(MuseumVM museum) { if (!ModelState.IsValid) { museum.MuseumType = new SelectList(museumtypeRepository.GetMuseumTypes(), "Id", "Name").ToList(); return(View("Add", museum)); } UserAccounts u = new UserAccounts(); if (museum.PasswordHash == museum.PasswordSalt) { string password = museum.PasswordHash; u.PasswordSalt = GeneratePassword.GenerateSalt(); u.PasswordHash = GeneratePassword.GenerateHash(password, u.PasswordSalt); u.Username = museum.Username; u.RegistrationDate = DateTime.Now; u.Active = true; userRepository.InsertUser(u); museumRepository.Save(); Museums m = new Museums(); m.MuseumTypeId = museum.MuseumTypeId; m.Name = museum.Name; m.UserId = u.Id; museumRepository.InsertMuseum(m); museumRepository.Save(); } return(RedirectToAction("Index")); }