Example #1
0
        public string Post([FromBody] ClientInfo client)
        {
            DataValid dv = new DataValid();

            if (!dv.IsValidDatas(client.LastName, client.FirstName, client.MiddleName, client.BirthDate, client.LoanSum))
            {
                return("Проверьте правильность введённых данных");
            }

            DateTime currentDate  = DateTime.Now;
            string   pathTemplate = templatesList[client.TemplateNum];

            string pathOutputFolder = foldersList[client.FolderNum];

            if (!Directory.Exists(pathOutputFolder))
            {
                return("Папка не найдена, обратитесь к администратору или выберите другую");
            }

            string templateName = templatesList[client.TemplateNum].Remove(0, templatesList[client.TemplateNum].LastIndexOf("\\"));

            templateName = templateName.Remove(templateName.IndexOf("."));
            string newFileName = templateName + " " + client.FirstName + " " + client.LastName + " от " + currentDate.ToLongDateString().Replace(".", "") + ".docx";
            string pathNewFile = pathOutputFolder + newFileName;

            Replacer repl = new Replacer();

            return(repl.NewDoc(pathTemplate, pathNewFile, client.LastName, client.FirstName, client.MiddleName, client.BirthDate, client.LoanSum, client.Image));
        }