Ejemplo n.º 1
0
        public async Task <List <University_MajorsDTO> > List([FromBody] University_MajorsFilterDTO university_MajorsFilterDTO)
        {
            University_MajorsFilter university_MajorsFilter = new University_MajorsFilter
            {
                UniversityId   = university_MajorsFilterDTO.UniversityId,
                UniversityCode = new StringFilter {
                    StartsWith = university_MajorsFilterDTO.UniversityCode
                },
                UniversityName = new StringFilter {
                    Contains = university_MajorsFilterDTO.UniversityName
                },
                MajorsId   = university_MajorsFilterDTO.MajorsId,
                MajorsCode = new StringFilter {
                    StartsWith = university_MajorsFilterDTO.MajorsCode
                },
                MajorsName = new StringFilter {
                    Contains = university_MajorsFilterDTO.MajorsName
                },
                Year = new StringFilter {
                    Equal = university_MajorsFilterDTO.Year
                },
                Skip      = university_MajorsFilterDTO.Skip,
                Take      = int.MaxValue,
                OrderType = OrderType.DESC,
                OrderBy   = University_MajorsOrder.MajorsName
            };

            List <University_Majors> universities = await university_MajorsService.List(university_MajorsFilter);

            List <University_MajorsDTO> university_MajorsDTOs = universities.Select(u => new University_MajorsDTO
            {
                Id                = u.Id,
                MajorsId          = u.MajorsId,
                MajorsCode        = u.MajorsCode,
                MajorsName        = u.MajorsName,
                UniversityId      = u.UniversityId,
                UniversityCode    = u.UniversityCode,
                UniversityName    = u.UniversityName,
                UniversityAddress = u.UniversityAddress,
                Year              = u.Year,
            }).ToList();

            return(university_MajorsDTOs);
        }
        public async Task <List <University_MajorsDTO> > List([FromBody] University_MajorsFilterDTO university_MajorsFilterDTO)
        {
            University_MajorsFilter university_MajorsFilter = new University_MajorsFilter
            {
                UniversityId   = university_MajorsFilterDTO.UniversityId,
                UniversityCode = university_MajorsFilterDTO.UniversityCode,
                UniversityName = university_MajorsFilterDTO.UniversityName,
                MajorsId       = university_MajorsFilterDTO.MajorsId,
                MajorsCode     = university_MajorsFilterDTO.MajorsCode,
                MajorsName     = university_MajorsFilterDTO.MajorsName,
                Year           = university_MajorsFilterDTO.Year,
                Skip           = university_MajorsFilterDTO.Skip,
                Take           = university_MajorsFilterDTO.Take,
                OrderType      = university_MajorsFilterDTO.OrderType,
                OrderBy        = university_MajorsFilterDTO.OrderBy
            };

            List <University_Majors> universities = await university_MajorsService.List(university_MajorsFilter);

            List <University_MajorsDTO> university_MajorsDTOs = universities.Select(u => new University_MajorsDTO(u)).ToList();

            return(university_MajorsDTOs);
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <University_Majors_SubjectGroupDTO> > Create([FromBody] University_Majors_SubjectGroupDTO university_Majors_SubjectGroupDTO)
        {
            if (university_Majors_SubjectGroupDTO == null)
            {
                university_Majors_SubjectGroupDTO = new University_Majors_SubjectGroupDTO();
            }

            University_Majors university_Majors = new University_Majors
            {
                MajorsId     = university_Majors_SubjectGroupDTO.MajorsId,
                UniversityId = university_Majors_SubjectGroupDTO.UniversityId,
                Year         = university_Majors_SubjectGroupDTO.Year
            };

            university_Majors = await University_MajorsService.Create(university_Majors);

            if (university_Majors.Id == Guid.Empty)
            {
                var university_Majors_ = await University_MajorsService.List(new University_MajorsFilter
                {
                    MajorsId     = university_Majors.MajorsId,
                    UniversityId = university_Majors.UniversityId,
                    Year         = new StringFilter {
                        Equal = university_Majors.Year
                    }
                });

                university_Majors = university_Majors_.FirstOrDefault();
            }

            University_Majors_SubjectGroup university_Majors_SubjectGroup = new University_Majors_SubjectGroup
            {
                SubjectGroupId      = university_Majors_SubjectGroupDTO.SubjectGroupId,
                University_MajorsId = university_Majors.Id,
                Benchmark           = university_Majors_SubjectGroupDTO.Benchmark,
                Quantity            = university_Majors_SubjectGroupDTO.Quantity,
                Note = university_Majors_SubjectGroupDTO.Note
            };

            university_Majors_SubjectGroup = await University_Majors_SubjectGroupService.Create(university_Majors_SubjectGroup);

            university_Majors_SubjectGroupDTO = new University_Majors_SubjectGroupDTO
            {
                MajorsId            = university_Majors_SubjectGroup.MajorsId,
                MajorsCode          = university_Majors_SubjectGroup.MajorsCode,
                MajorsName          = university_Majors_SubjectGroup.MajorsName,
                UniversityId        = university_Majors_SubjectGroup.UniversityId,
                UniversityCode      = university_Majors_SubjectGroup.UniversityCode,
                UniversityName      = university_Majors_SubjectGroup.UniversityName,
                SubjectGroupId      = university_Majors_SubjectGroup.SubjectGroupId,
                SubjectGroupCode    = university_Majors_SubjectGroup.SubjectGroupCode,
                SubjectGroupName    = university_Majors_SubjectGroup.SubjectGroupName,
                University_MajorsId = university_Majors_SubjectGroup.University_MajorsId,
                Quantity            = university_Majors_SubjectGroup.Quantity,
                Note      = university_Majors_SubjectGroup.Note,
                Benchmark = university_Majors_SubjectGroup.Benchmark,
                Id        = university_Majors_SubjectGroup.Id,
                Year      = university_Majors_SubjectGroup.Year,
                Errors    = university_Majors_SubjectGroup.Errors
            };
            if (university_Majors_SubjectGroup.HasError)
            {
                return(BadRequest(university_Majors_SubjectGroupDTO));
            }
            return(Ok(university_Majors_SubjectGroupDTO));
        }