public ActionResult ReportServer(ReportServerConfigDTO model) { try { var conServer = new Config { Description = model.ReportServerUri, Value = model.ReportServerUri, ConfigType = ConfigType.ReportServer }; _configRepository.Save(conServer); var conUsername = new Config { Description = model.ReportServerUsername, Value = model.ReportServerUsername, ConfigType = ConfigType.ReportServerUsername }; _configRepository.Save(conUsername); var conPassword = new Config { Description = "", Value = IcoderEncryption.EncryptString(model.ReportServerPassword), ConfigType = ConfigType.ReportServerPassword }; _configRepository.Save(conPassword); ModelState.AddModelError("","Report server settings saved successfully"); return View(model); } catch (DomainValidationException ve) { ve.DomainValidationErrors(ModelState); return View(model); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return View(model); } }
public void Save(Config entity) { ValidationResultInfo vri = Validate(entity); if (!vri.IsValid) throw new DomainValidationException(vri, "Configurations Details not Valid"); DateTime date = DateTime.Now; Config tbl = _context.Configurations.FirstOrDefault(s => s.ConfigType == entity.ConfigType); if (tbl == null) { tbl = new Config(); tbl.ConfigType = entity.ConfigType; tbl.Id = Guid.NewGuid(); _context.Configurations.Add(tbl); } tbl.Value = entity.Value; tbl.Description = entity.Description; tbl.Value = entity.Value; tbl.ConfigType = entity.ConfigType; tbl.ClientId = entity.ClientId ?? null; _context.SaveChanges(); }
public ValidationResultInfo Validate(Config itemToValidate) { return itemToValidate.BasicValidation(); }