public int?RegisterElderCurator(ElderCuratorViewModel elderCuratorVM) { //User user = new User() //{ // Login = elderCuratorVM.User.Login, // Password = elderCuratorVM.User.Password, // FirstName = elderCuratorVM.User.FirstName, // SurName = elderCuratorVM.User.SurName, // Role = context.Roles.SingleOrDefault(r => r.Name == elderCuratorVM.User.Role.Name), //}; //context.Users.Add(user); ElderCurator elderCurator = new ElderCurator() { User = new User() { Login = elderCuratorVM.User.Login, Password = elderCuratorVM.User.Password, FirstName = elderCuratorVM.User.FirstName, SurName = elderCuratorVM.User.SurName, Role = context.Roles.SingleOrDefault(r => r.Name == elderCuratorVM.User.Role.Name), }, Faculty = context.Faculties.SingleOrDefault(f => f.Id == elderCuratorVM.Faculty.Id), }; context.ElderCurators.Add(elderCurator); context.SaveChanges(); return(1); }
public IActionResult GetElder(int userId) { ElderCuratorViewModel viewModel = repository.GetElder(userId); if (viewModel != null) { return(Ok(viewModel)); } return(NotFound("Старший куратор с таким Id не существует!")); }
public IActionResult RegisterElderCurator([FromBody] ElderCuratorViewModel elderCuratorVM) { int?result = repository.RegisterElderCurator(elderCuratorVM); if (result != null) { return(Ok(result)); } else { return(BadRequest("Error!")); } }