示例#1
0
        public async Task <IActionResult> CreateDocFile(string typeDocument)
        {
            switch (typeDocument)
            {
            case ".docx":
            {
                var model = await _serviceManager.Staff.StaffsList();

                int          countRecord = model.Count();
                var          document    = new DocParse();
                MemoryStream bais        = new MemoryStream(document.CreateTableDoc(model, countRecord).ToArray());
                string       file_type   = "application/docx";
                string       file_name   = "prikaz.docx";
                return(File(bais, file_type, file_name));
            }

            case ".xlsx":
            {
                var model = await _serviceManager.Staff.StaffsList();

                int          countRecord = model.Count();
                var          document    = new XlsxParser();
                MemoryStream bais        = new MemoryStream(document.CreateTableXlsx(model, countRecord).ToArray());
                string       file_type   = "application/xlsx";
                string       file_name   = "prikaz.xlsx";
                return(File(bais, file_type, file_name));
            }
            }
            return(View());
        }
示例#2
0
        public async Task <IActionResult> AppointAndTransferDoc(string StaffId, string PositionId, string SubDepartmenId)
        {
            int _staffId = int.Parse(StaffId);
            var staff    = await _serviceManager.Staff.GetStaffById(_staffId);

            var document         = new DocParse();
            int _positionId      = int.Parse(PositionId);
            int _subDepartmentId = int.Parse(SubDepartmenId);
            var positions        = _dataManager.Positiond.GetPositions();
            var positionOld      = staff.Position;
            var subDepartmentOld = staff.SubDepartmen;

            staff.Position = new PositionViewModel
            {
                Name = positions.FirstOrDefault(x => x.PositionId == _positionId).Name
            };
            var subdepartmentFromDb = await _dataManager.SubDepartment.GetSubDepartmentById(_subDepartmentId);

            staff.SubDepartmen = new SubDepartmentViewModel {
                Name = subdepartmentFromDb.Name
            };

            MemoryStream bais      = new MemoryStream(document.AppointAndTransfer(staff, positionOld, subDepartmentOld).ToArray());
            string       file_type = "application/docx";
            string       file_name = "prikaz.docx";

            return(File(bais, file_type, file_name));

            // return RedirectToAction("GetStaff", "Home", new { model.StaffId });
        }