Пример #1
0
        private ProfessionFilter ConvertFilterDTOToFilterEntity(Profession_ProfessionFilterDTO Profession_ProfessionFilterDTO)
        {
            ProfessionFilter ProfessionFilter = new ProfessionFilter();

            ProfessionFilter.Selects   = ProfessionSelect.ALL;
            ProfessionFilter.Skip      = Profession_ProfessionFilterDTO.Skip;
            ProfessionFilter.Take      = Profession_ProfessionFilterDTO.Take;
            ProfessionFilter.OrderBy   = Profession_ProfessionFilterDTO.OrderBy;
            ProfessionFilter.OrderType = Profession_ProfessionFilterDTO.OrderType;

            ProfessionFilter.Id        = Profession_ProfessionFilterDTO.Id;
            ProfessionFilter.Code      = Profession_ProfessionFilterDTO.Code;
            ProfessionFilter.Name      = Profession_ProfessionFilterDTO.Name;
            ProfessionFilter.StatusId  = Profession_ProfessionFilterDTO.StatusId;
            ProfessionFilter.RowId     = Profession_ProfessionFilterDTO.RowId;
            ProfessionFilter.CreatedAt = Profession_ProfessionFilterDTO.CreatedAt;
            ProfessionFilter.UpdatedAt = Profession_ProfessionFilterDTO.UpdatedAt;
            return(ProfessionFilter);
        }
Пример #2
0
        public async Task <ActionResult <int> > Count([FromBody] Profession_ProfessionFilterDTO Profession_ProfessionFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            ProfessionFilter ProfessionFilter = ConvertFilterDTOToFilterEntity(Profession_ProfessionFilterDTO);

            ProfessionFilter = await ProfessionService.ToFilter(ProfessionFilter);

            int count = await ProfessionService.Count(ProfessionFilter);

            return(count);
        }
Пример #3
0
        public async Task <ActionResult <List <Profession_ProfessionDTO> > > List([FromBody] Profession_ProfessionFilterDTO Profession_ProfessionFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            ProfessionFilter ProfessionFilter = ConvertFilterDTOToFilterEntity(Profession_ProfessionFilterDTO);

            ProfessionFilter = await ProfessionService.ToFilter(ProfessionFilter);

            List <Profession> Professions = await ProfessionService.List(ProfessionFilter);

            List <Profession_ProfessionDTO> Profession_ProfessionDTOs = Professions
                                                                        .Select(c => new Profession_ProfessionDTO(c)).ToList();

            return(Profession_ProfessionDTOs);
        }
Пример #4
0
        public async Task <ActionResult> ExportTemplate([FromBody] Profession_ProfessionFilterDTO Profession_ProfessionFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            string path = "Templates/Profession_Template.xlsx";

            byte[]       arr    = System.IO.File.ReadAllBytes(path);
            MemoryStream input  = new MemoryStream(arr);
            MemoryStream output = new MemoryStream();
            dynamic      Data   = new ExpandoObject();

            using (var document = StaticParams.DocumentFactory.Open(input, output, "xlsx"))
            {
                document.Process(Data);
            };
            return(File(output.ToArray(), "application/octet-stream", "Profession.xlsx"));
        }
Пример #5
0
        public async Task <ActionResult> Export([FromBody] Profession_ProfessionFilterDTO Profession_ProfessionFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            MemoryStream memoryStream = new MemoryStream();

            using (ExcelPackage excel = new ExcelPackage(memoryStream))
            {
                #region Profession
                var ProfessionFilter = ConvertFilterDTOToFilterEntity(Profession_ProfessionFilterDTO);
                ProfessionFilter.Skip = 0;
                ProfessionFilter.Take = int.MaxValue;
                ProfessionFilter      = await ProfessionService.ToFilter(ProfessionFilter);

                List <Profession> Professions = await ProfessionService.List(ProfessionFilter);

                var ProfessionHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Code",
                        "Name",
                        "StatusId",
                        "RowId",
                        "Used",
                    }
                };
                List <object[]> ProfessionData = new List <object[]>();
                for (int i = 0; i < Professions.Count; i++)
                {
                    var Profession = Professions[i];
                    ProfessionData.Add(new Object[]
                    {
                        Profession.Id,
                        Profession.Code,
                        Profession.Name,
                        Profession.StatusId,
                        Profession.RowId,
                        Profession.Used,
                    });
                }
                excel.GenerateWorksheet("Profession", ProfessionHeaders, ProfessionData);
                #endregion

                #region Status
                var StatusFilter = new StatusFilter();
                StatusFilter.Selects   = StatusSelect.ALL;
                StatusFilter.OrderBy   = StatusOrder.Id;
                StatusFilter.OrderType = OrderType.ASC;
                StatusFilter.Skip      = 0;
                StatusFilter.Take      = int.MaxValue;
                List <Status> Statuses = await StatusService.List(StatusFilter);

                var StatusHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Code",
                        "Name",
                    }
                };
                List <object[]> StatusData = new List <object[]>();
                for (int i = 0; i < Statuses.Count; i++)
                {
                    var Status = Statuses[i];
                    StatusData.Add(new Object[]
                    {
                        Status.Id,
                        Status.Code,
                        Status.Name,
                    });
                }
                excel.GenerateWorksheet("Status", StatusHeaders, StatusData);
                #endregion
                excel.Save();
            }
            return(File(memoryStream.ToArray(), "application/octet-stream", "Profession.xlsx"));
        }