コード例 #1
0
        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);
        }
コード例 #2
0
        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");
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
        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));
        }
コード例 #6
0
 public async Task <ActionResultDto <LecturerGroupDto> > CreateLecturerGroup(LecturerGroupDto lg)
 {
     return(await _lecturerGroupService.AddLecturerGroup(lg));
 }
コード例 #7
0
 public async Task <LecturerGroupDto> CreateLecturerGroup(LecturerGroupDto newLecturerGroup)
 {
     return(await httpClient.PostJsonAsync <LecturerGroupDto>("api/LecturerGroup", newLecturerGroup));
 }
コード例 #8
0
 public async Task <LecturerGroupDto> UpdateLecturerGroup(LecturerGroupDto LecturerGroup)
 {
     return(await httpClient.PutJsonAsync <LecturerGroupDto>("api/LecturerGroup", LecturerGroup));
 }