/// <summary>
        /// Load edge fields by account + set edge type for each field
        /// </summary>
        public static List <EdgeField> LoadEdgeFields(int accountId, Dictionary <string, EdgeType> edgeTypes, SqlConnection connection)
        {
            var edgeFields = new List <EdgeField>();

            try
            {
                using (var cmd = SqlUtility.CreateCommand("MD_EdgeField_Get", CommandType.StoredProcedure))
                {
                    cmd.Parameters.AddWithValue("@accountID", accountId);
                    cmd.Connection = connection;

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            EdgeField field = null;
                            Type      type  = Type.GetType(reader["FieldType"].ToString());
                            if (type == null)
                            {
                                field = new SystemField();
                            }
                            else
                            {
                                field = Activator.CreateInstance(type) as EdgeField;
                            }

                            if (field != null)
                            {
                                field.FieldID       = int.Parse(reader["FieldID"].ToString());
                                field.Name          = reader["Name"].ToString();
                                field.DisplayName   = reader["DisplayName"].ToString();
                                field.FieldEdgeType = edgeTypes.Values.FirstOrDefault(x => x.TypeID == int.Parse(reader["FieldTypeID"].ToString()));

                                edgeFields.Add(field);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error while trying to get extra fields from DB", ex);
            }
            return(edgeFields);
        }
 public async Task <JsonResult> SaveField(SystemField field)
 {
     return(Json(await _fieldLogic.SaveField(field)));
 }