Exemple #1
0
 public void ChangeSubplatformSetting(Subplatform subplatform, SubplatformSetting setting)
 {
     InitNonExistingRepo();
     if (subplatform == null)
     {
         throw new Exception("No subplatform has been provided");
     }
     if (setting.Subplatform.SubplatformId != subplatform.SubplatformId)
     {
         throw new Exception(
                   "Setting doesn't have same subplatform anymore. Settings cannot be removed from subplatforms, only disabled.");
     }
     if (!subplatform.Settings.Contains(setting))
     {
         if (subplatform.Settings.FirstOrDefault(sstc => sstc.SettingName.Equals(setting.SettingName)) is null)
         {
             subplatform.Settings.Add(setting);
         }
         else
         {
             subplatform.Settings[
                 subplatform.Settings.FindIndex(sstc => sstc.SettingName.Equals(setting.SettingName))] = setting;
         }
     }
     SubplatformRepo.UpdateSubplatform(subplatform);
     uowManager.Save();
 }
Exemple #2
0
        public SubplatformSetting AddSubplatformSetting(Setting.Platform settingName, int subplatformId, string value,
                                                        bool isEnabled = false)
        {
            InitNonExistingRepo();
            Subplatform subplatform = SubplatformRepo.ReadSubplatform(subplatformId);

            if (subplatform == null)
            {
                throw new Exception("Subplatform with id (" + subplatformId +
                                    ") doesn't exist"); //Subplatform bestaat niet
            }
            SubplatformSetting subplatformSetting = new SubplatformSetting
            {
                SettingName = settingName,
                Subplatform = subplatform,
                Value       = value,
                IsEnabled   = isEnabled
            };

            subplatformSetting = SubplatformRepo.CreateSubplatformSetting(subplatformSetting);
            uowManager.Save();
            return(subplatformSetting);
        }
Exemple #3
0
        public SubplatformSetting CreateSubplatformSetting(SubplatformSetting subplatformSetting)
        {
            subplatformSetting = ctx.SubplatformSettings.Add(subplatformSetting);

            try
            {
                ctx.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
            }

            return(subplatformSetting);
        }
Exemple #4
0
 public void UpdateSubplatformSetting(SubplatformSetting subplatformSetting)
 {
     ctx.SubplatformSettings.Attach(subplatformSetting);
     ctx.Entry(subplatformSetting).State = EntityState.Modified;
     ctx.SaveChanges();
 }