public ActionResult UpdateGeneralSettings(Models.ConfigurationModels.GeneralSystem GeneralModel)
        {
            try
            {
                if (!ModelState.IsValid)
                    throw new ArgumentException();

                var config = new Models.Configuration();
                config.WebsiteAddress = GeneralModel.WebsiteAddress;
                config.Save();
                return Json(new { success = true });
            }
            catch (Exception ex)
            {
                return Json(new { _error = true, message = ex.Message });
            }
        }
        public ActionResult UpdateSmtpSettings(Models.ConfigurationModels.SmtpConfiguration Model)
        {
            if (!ModelState.IsValid)
                throw new ArgumentException();

            var config = new Models.Configuration();
            config.SmtpServer = Model.Server;
            config.SmtpPort = Model.Port;
            config.SmtpUsername = Model.Username;
            if(Model.Password != DummyPassword) // only update it if its not the dummy
                config.SmtpPassword = Helpers.Encrypter.Encrypt(Model.Password, Helpers.Encrypter.GetCpuId()); // TODO encrypt this
            config.SmtpUseSsl = Model.UseSsl;
            config.SmtpSender = Model.Sender;
            config.Save();

            return Json(new { success = true });
        }
        private ActionResult SaveConfig(object PartialModel)
        {
            if (!ModelState.IsValid)
            {
                List<string> errors = new List<string>();
                foreach (var t in ModelState.Values)
                    errors.AddRange(t.Errors.Where(x => !String.IsNullOrWhiteSpace(x.ErrorMessage)).Select(x => x.ErrorMessage));
                throw new HttpException((int)HttpStatusCode.BadRequest, String.Join(Environment.NewLine, errors.ToArray()));
            }

            var config = new Models.Configuration();
            foreach(var property in PartialModel.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.SetProperty))
            {
                var configProperty = config.GetType().GetProperty(property.Name);
                if(configProperty != null)
                    configProperty.SetValue(config, property.GetValue(PartialModel, null), null);
            }
            config.Save();

            return Json(new { success = true });
        }
 public override void Startup()
 {
     base.Startup();
     NextPvrWebConsole.Models.Configuration config = new Models.Configuration();
     config.UserBaseRecordingDirectory = @"C:\temp";
     config.Save();
 }