public bool InsertStandardDataType(StandardDataTypeModel model) { AutomationStandardsContext db = new AutomationStandardsContext(); StandardDataType Result = new StandardDataType(); Result.DataTypeName = model.StandardDataTypeName; Result.SQLDataType = model.SQLDataType; db.StandardDataType.Add(Result); try { db.SaveChanges(); model.StandardDataTypeID = Result.DataTypeID; 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 StandardDataTypeModel SelectSingleStandardDataType(int DataTypeID) { AutomationStandardsContext db = new AutomationStandardsContext(); StandardDataTypeModel Result = (from d in db.StandardDataType where d.DataTypeID == DataTypeID select new StandardDataTypeModel { StandardDataTypeID = d.DataTypeID, StandardDataTypeName = d.DataTypeName, SQLDataType = d.SQLDataType }).First(); return(Result); }