Ejemplo n.º 1
0
        public async Task<string> GetContractAsync(string path, int id)
        {
            if (!string.IsNullOrEmpty(path))
            {
                var cadet = await _context.Cadets.GetAsync(id);
                if (cadet != null)
                {
                    var group = cadet.Group;
                    if (group != null)
	                {
                        string templatePath = path + "Договор.docx";
                        if (!Directory.Exists(path + "/CadetFiles/"+ id))
                        {
                            Directory.CreateDirectory(path + "/CadetFiles/" + id);           
                        }
                        else
                        {
                            if (File.Exists(path + "/CadetFiles/" + id + "/Договор.pdf"))
                            {
                                return path + "/CadetFiles/" + id + "/Договор.pdf";
                            }       
                        }              
                        
                        string saveAsPath = path + "/CadetFiles/" + id + "/Договор.pdf";

                        ContractReport report = new ContractReport(templatePath, saveAsPath)
                        {
                            LastName = cadet.LastName,
                            Name = cadet.Name,
                            MiddleName = cadet.MiddleName,
                            BirthDay = cadet.BirthDay,
                            BirthPlace = cadet.BirthPlace,
                            ContractNumber = cadet.Id,
                            EnrollmentDate = (DateTime)cadet.EnrollmentDate,
                            PassportIssueBy = cadet.PassportIssueBy,
                            PassportIssueDate = cadet.PassportIssueDate,
                            PassportNumber = cadet.PassportNumber,
                            PassportNumberId = cadet.PassportNumberId,
                            PhoneMobile = cadet.PhoneMobile,
                            Registration = cadet.Registration,
                            StartDate = group.TheoryStartDate > group.PracticeStartDate ? group.TheoryStartDate : group.PracticeStartDate,
                            Program = group.TrainingProgram.Program,
                            GroupType = group.GroupType,
                            Cost = group.TrainingProgram.Cost,
                            TheoryHours = group.TrainingProgram.TheoryHours,
                            PracticeHours = group.TrainingProgram.PracticeHours,
                        };
                        return report.GetReport();
	                }
                    
                }
            }
            return null;
        }
Ejemplo n.º 2
0
 public static void ReportTwo()
 {
     ContractReport obj = new ContractReport(@"D:/Договор.docx", @"D:/new2.pdf")
     {
         BirthDay = new DateTime(1994, 2, 6),
         BirthPlace = "г. Климовичи",
         EnrollmentDate = DateTime.Now,
         LastName = "Николайченко",
         MiddleName = "Владимирович",
         Name = "Иван",
         PassportIssueBy = "Климовичский РОВД",
         PassportIssueDate = new DateTime(2009, 3, 5),
         PassportNumber = "КВ1653568",
         PhoneMobile = "+375448965230",
         Program = "Категория C",
         Registration = "Могилёв, Космонавтов 11",
         ContractNumber = 56,
         Cost = 3600000,
         GroupType = "ATM-60",
         PassportNumberId = "2131drg141ada",
         PracticeHours = 48,
         StartDate = DateTime.Now.Date,
         TheoryHours = 65,
     };
     Console.WriteLine(obj.GetReport());
 }