public bool InsertStandardGroup(StandardGroupModel model) { AutomationStandardsContext db = new AutomationStandardsContext(); StandardGroup Result = new StandardGroup(); Result.StandardGroupName = model.StandardGroupName; db.StandardGroup.Add(Result); try { db.SaveChanges(); model.StandardGroupID = Result.StandardGroupID; return(true); } catch (DbEntityValidationException ex) { string body = ""; foreach (var eve in ex.EntityValidationErrors) { body += string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); body += "<br>"; foreach (var ve in eve.ValidationErrors) { body += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } //GlobalFunctions gf = new //GlobalFunctions(); //gf.SendErrorModelEmail(this.GetType().Name, body); return(false); } }
public StandardGroupModel SelectSingleStandardGroup(int GroupID) { AutomationStandardsContext db = new AutomationStandardsContext(); StandardGroupModel Result = (from d in db.StandardGroup where d.StandardGroupID == GroupID select new StandardGroupModel { StandardGroupID = d.StandardGroupID, StandardGroupName = d.StandardGroupName }).First(); return(Result); }