public async Task <LecturerGroupDto?> UpdateLecturerGroup(LecturerGroupDto lecturerGroupDto) { var result = await _context.LecturerGroups.FindAsync(lecturerGroupDto.LecturerGroupId); if (result != null) { result.Title = lecturerGroupDto.Title; await _context.SaveChangesAsync(); return(_mapper.Map <LecturerGroupDto>(result)); } return(null); }
protected async Task HandleValidSubmit() { LecturerGroupDto result = null; if (LecturerGroup.LecturerGroupId != 0) { result = await LecturerGroupService.UpdateLecturerGroup(LecturerGroup); } else { result = await LecturerGroupService.CreateLecturerGroup(LecturerGroup); } NavigationManager.NavigateTo($"/lecturergroupsview"); }
protected async override Task OnInitializedAsync() { int.TryParse(Id, out int lecturerGroupId); if (lecturerGroupId != 0) { PageHeaderText = "Edit LecturerGroup"; LecturerGroup = await LecturerGroupService.GetLecturerGroup(int.Parse(Id)); } else { PageHeaderText = "Create LecturerGroup"; LecturerGroup = new LecturerGroupDto { }; } Lecturers = (await LecturerService.GetLecturers()).ToList(); }
public async Task <ActionResult <LecturerGroupDto?> > UpdateLecturerGroupDto(LecturerGroupDto lecturerGroup) { try { var updatedLecturerGroup = await _lecturerGroupService.GetLectureGroup(lecturerGroup.LecturerGroupId); if (updatedLecturerGroup == null) { return(NotFound($"Module run with id = {lecturerGroup.LecturerGroupId } was not found!")); } return(await _lecturerGroupService.UpdateLecturerGroup(lecturerGroup)); } catch (Exception ex) { _logger.LogError(SR.ErrorRetrievingDataFromDataBase, ex); return(StatusCode(StatusCodes.Status500InternalServerError, SR.ErrorUpdatingDatabase)); } }
public async Task <ActionResultDto <LecturerGroupDto> > AddLecturerGroup(LecturerGroupDto lecturerGroupDto) { var lecturergroup = new LecturerGroup(); _mapper.Map(lecturerGroupDto, lecturergroup); if (lecturergroup == null) { return(new ActionResultDto <LecturerGroupDto>("You can not add an empty lecturer group ")); } foreach (var lg in _context.LecturerGroups) { if (lg.Title == lecturergroup.Title) { return(new ActionResultDto <LecturerGroupDto>("The group is already has been added.")); } } var result = await _context.LecturerGroups.AddAsync(lecturergroup); await _context.SaveChangesAsync(); return(_mapper.Map <LecturerGroupDto>(result.Entity)); }
public async Task <ActionResultDto <LecturerGroupDto> > CreateLecturerGroup(LecturerGroupDto lg) { return(await _lecturerGroupService.AddLecturerGroup(lg)); }
public async Task <LecturerGroupDto> CreateLecturerGroup(LecturerGroupDto newLecturerGroup) { return(await httpClient.PostJsonAsync <LecturerGroupDto>("api/LecturerGroup", newLecturerGroup)); }
public async Task <LecturerGroupDto> UpdateLecturerGroup(LecturerGroupDto LecturerGroup) { return(await httpClient.PutJsonAsync <LecturerGroupDto>("api/LecturerGroup", LecturerGroup)); }