//Get Attributes based on Entity called public int AutoCreateEntity(EntityAutoRequestModel model) { int entityID = 0; List <int> attrIds = new List <int>(); EVA_EntityRequestModel entity = new EVA_EntityRequestModel(); entity.WebsiteId = model.WebsiteId; entity.Name = model.EntityName; entity.Slug = UtilityService.camelCaseToDash(model.EntityName); entityID = Insert(entity); foreach (string Attribute in model.Attributes) { string Name = Attribute; string Slug = UtilityService.camelCaseToDash(Name); int AttrId = AttrService.GetAutoAttributes(Name, Slug); attrIds.Add(AttrId); } AttrService.BulkInsertAttrIds(entityID, attrIds.ToArray()); return(entityID); }
public HttpResponseMessage Add(EVA_EntityRequestModel model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); response.Item = _EntityServices.Insert(model); return(Request.CreateResponse(response)); }
// update public void Update(EVA_EntityRequestModel model) { DataProvider.ExecuteNonQuery(GetConnection, "dbo.EVA_Entity_Update" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@ID", model.ID); paramCollection.AddWithValue("@Name", model.Name); paramCollection.AddWithValue("@Slug", model.Slug); paramCollection.AddWithValue("@WebsiteId", model.WebsiteId); }, returnParameters : delegate(SqlParameterCollection param) { } ); }
public int Insert(EVA_EntityRequestModel model) { int oid = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.EVA_Entity_Insert" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@WebsiteId", model.WebsiteId); paramCollection.AddWithValue("@Name", model.Name); paramCollection.AddWithValue("@Slug", model.Slug); SqlParameter p = new SqlParameter("@OID", System.Data.SqlDbType.Int); p.Direction = System.Data.ParameterDirection.Output; paramCollection.Add(p); }, returnParameters : delegate(SqlParameterCollection param) { int.TryParse(param["@OID"].Value.ToString(), out oid); } ); return(oid); }