Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,GroupId,TemplateId")] Group_Template group_Template)
        {
            if (id != group_Template.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(group_Template);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Group_TemplateExists(group_Template.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GroupId"]    = new SelectList(_context.Group, "GroupId", "GroupId", group_Template.GroupId);
            ViewData["TemplateId"] = new SelectList(_context.Template, "TemplateId", "TemplateId", group_Template.TemplateId);
            return(View(group_Template));
        }
Ejemplo n.º 2
0
        public Report_Template GetPrinterSettings(string metaData, Model_PDFFinder context)
        {
            Report_Template report = context.Report_Template.Where(x => x.report_name == metaData).FirstOrDefault();

            if (report != null)
            {
                return(report);
            }
            Group_Template group = context.Group_Template.Where(x => metaData.Contains(x.group_name)).FirstOrDefault();

            if (group == null)
            {
                return(null);
            }
            List <Report_Template> reports = context.Report_Template.Where(x => x.report_name.Contains(group.group_name)).ToList();
            string printerName, paperFormat;
            bool?  reportDuplex;

            if (reports.Count != 0)
            {
                Report_Template defaultReport = reports.First();

                printerName = reports.All(x => x.printer_name == defaultReport.printer_name) ? defaultReport.printer_name : group.printer_name;

                reportDuplex = reports.All(x => x.duplex == defaultReport.duplex) ? defaultReport.duplex : group.duplex;

                paperFormat = reports.All(x => x.paper_format == defaultReport.paper_format) ? defaultReport.paper_format : group.paper_format;
            }
            else
            {
                printerName = group.printer_name;

                reportDuplex = group.duplex;

                paperFormat = group.paper_format;
            }

            Report_Template printerSettings = new Report_Template()
            {
                report_name  = metaData,
                printer_name = printerName,
                duplex       = reportDuplex,
                paper_format = paperFormat
            };

            return(printerSettings);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("GroupId,TemplateId")] Group_Template group_Template)
        {
            var GroupId = group_Template.GroupId;

            var check = from gt in _context.Group_Template
                        where gt.GroupId == group_Template.GroupId && gt.TemplateId == group_Template.TemplateId
                        select gt;

            if (ModelState.IsValid && check.Count() == 0)
            {
                _context.Add(group_Template);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Template", "Groups", new { id = GroupId }));
            }

            return(RedirectToAction("Template", "Groups", new { id = GroupId }));
        }