public static string AddUnit(ShowableUnit unit) { try { using (var db = new BarProjectEntities()) { var q = db.UnitTypes.FirstOrDefault(x => x.type_name == unit.Type); if (q != null) { db.addUnit(unit.Name, unit.Factor, q.id); } else { throw new ArgumentException("Problem with type name!"); } } } catch (Exception ex) { var message = ex.Message; if (ex.InnerException != null) { message += "\nInner:" + ex.InnerException.Message; } return(message); } return(""); }
private bool IsUnitEmpty(ShowableUnit unit) { return(unit.Name == null && unit.Type == null); }