public HostRuntimeConfiguration()
 {
     Server = new List<ServiceTypeConfiguration>();
     SuperUser = new UserElement();
     Audit = new AuditElement();
     LogInfo = new LogElement();
 }
Ejemplo n.º 2
0
        public ActionResult Add(AuditElementViewModel model)
        {
            var userId         = User.Identity.GetUserId();
            var submitDateTime = DateTime.Now;

            model.CreateDateTime   = submitDateTime;
            model.ModifiedDateTime = submitDateTime;
            model.CreatedById      = userId;
            model.ModifiedById     = userId;

            var auditSection   = _context.AuditSections.Single(a => a.Id == model.SectionId);
            var auditTemaplate = _context.AuditTemplates.Single(a => a.Id == auditSection.AuditTemplateId);

            if (ModelState.IsValid)
            {
                var auditElement = new AuditElement();

                AutoMapper.Mapper.Map(model, auditElement);

                auditSection.ModifiedById       = userId;
                auditSection.ModifiedDateTime   = submitDateTime;
                auditTemaplate.ModifiedById     = userId;
                auditTemaplate.ModifiedDateTime = submitDateTime;

                _context.AuditElements.Add(auditElement);
                _context.SaveChanges();

                var auditTemplateId = _context.AuditSections.Single(a => a.Id == auditElement.SectionId).AuditTemplateId;

                return(RedirectToAction("Details", "AuditTemplates", new { id = auditTemplateId }));
            }



            model.Section = new AuditSectionViewModel {
                AuditTemplate = new AuditTemplateViewModel()
            };

            AutoMapper.Mapper.Map(auditSection, model.Section);
            AutoMapper.Mapper.Map(auditTemaplate, model.Section.AuditTemplate);

            return(View("Form", model));
        }