Beispiel #1
0
        public async Task <IActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(new BadRequestResult());
            }
            Lecturer lc = await _LecturerRepository.GetByIdAsync(id);

            if (lc == null)
            {
                return(new NotFoundResult());
            }
            return(View(lc));
        }
        public async Task <ApplicationResponse <LecturerDto> > GetByIdAsync(string lecturerId)
        {
            Guid lecturerGuid = new Guid();

            if (Guid.TryParse(lecturerId, out lecturerGuid))
            {
                Lecturer lecturer = await _lecturerRepository.GetByIdAsync(lecturerGuid);

                var appResp = new ApplicationResponse <LecturerDto>();

                if (lecturer != null)
                {
                    LecturerDto dto = _mapper.Map <LecturerDto>(lecturer);
                    appResp.Response = dto;
                    appResp.Message  = "OK";
                    return(appResp);
                }
                else
                {
                    appResp.AddError("Not Found");
                    return(appResp);
                }
            }
            else
            {
                var response = new ApplicationResponse <LecturerDto>();
                response.Response = new LecturerDto();
                response.AddError("Identifier is in a wrong format.");
                return(response);
            }
        }