Example #1
0
        public string Create([Bind(Exclude = "Id")] Educ Model)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            string msg;

            try
            {
                if (ModelState.IsValid)
                {
                    db.Educs.Add(Model);

                    db.SaveChanges();
                    msg = "Сохранено успешно";
                }
                else
                {
                    msg = "Данные не прошли проверку ввода";
                }
            }
            catch (Exception ex)
            {
                msg = "Произошла ошибка:" + ex.Message;
            }
            return(msg);
        }
Example #2
0
        public string Delete(int Id)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            Educ Educs = db.Educs.Find(Id);

            db.Educs.Remove(Educs);
            db.SaveChanges();
            return("Удалено успешно");
        }
Example #3
0
 public bool Is(IObject PropertyStat)
 {
     if (PropertyStat is EducStat)
     {
         if ((PropertyStat as EducStat).Educ != null)
         {
             foreach (EEduc x in (PropertyStat as EducStat).Educ)
             {
                 if (Educ.Contains(x) == false)
                 {
                     System.Windows.MessageBox.Show("Потрібно " + x.ToString());
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Example #4
0
 public bool NegativeEffect(IObject otherStat)
 {
     if (otherStat is EducStat)
     {
         if ((otherStat as EducStat).Educ != null)
         {
             foreach (EEduc x in (otherStat as EducStat).Educ)
             {
                 if (Educ.Contains(x))
                 {
                     Educ.Remove(x);
                     OnPropertyChanged("HighestEduc");
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Example #5
0
        public string Edit(Educ Model)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            string msg;

            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(Model).State = EntityState.Modified;
                    db.SaveChanges();
                    msg = "Сохранено успешно";
                }
                else
                {
                    msg = "Данные не прошли проверку ввода";
                }
            }
            catch (Exception ex)
            {
                msg = "Произошла ошибка:" + ex.Message;
            }
            return(msg);
        }