public async Task <object> Post(CreateTeacher request) { var response = new BaseResponse(); var entity = request.ConvertTo <Teacher>(); var result = await _teacherService.Create(entity); if (request.CreateNewUserLogin) { var userLogin = new CreateUser() { FirstName = entity.FirstName, LastName = entity.LastName, DisplayName = entity.FirstName + " " + entity.LastName, UserName = entity.FirstName.ToLower() + entity.LastName.ToLower(), Password = entity.FirstName.ToLower() + entity.LastName.ToLower(), RoleId = RoleEnum.Teacher.ToDescription() }; await _userApiService.Post(userLogin); } response.Success = true; response.StatusCode = (int)HttpStatusCode.Created; response.Message = "Create teacher success"; response.Results = result; return(response); }
public async Task <object> Post(CreateStudent request) { var response = new BaseResponse(); var entity = request.ConvertTo <Student>(); var result = await _studentService.Create(entity); if (request.CreateNewUserLogin) { var userLogin = new CreateUser() { FirstName = entity.FirstName, LastName = entity.LastName, DisplayName = entity.FirstName + " " + entity.LastName, UserName = entity.StudentCode, Password = entity.DateOfBirth.HasValue ? entity.DateOfBirth.Value.ToString("yyyy-MM-dd") : entity.StudentCode, RoleId = RoleEnum.Student.ToDescription() }; await _userService.Post(userLogin); } response.Success = true; response.StatusCode = (int)HttpStatusCode.Created; response.Message = "Create student success"; response.Results = result.ConvertTo <StudentDto>(); return(response); }
protected async Task HandleSubmit() { if (_user.Id == 0) { await UserApiService.Post(_user); } else { await UserApiService.Put(_user.Id, _user); } NavigationManager.NavigateTo("admin/users"); }