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); }
public string Delete(int Id) { ApplicationDbContext db = new ApplicationDbContext(); Educ Educs = db.Educs.Find(Id); db.Educs.Remove(Educs); db.SaveChanges(); return("Удалено успешно"); }
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); }
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); }
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); }