public static int Save(int entityId, EntityType entityTypeToSave) { BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection(); if (entityId <= 0) saveBrokenRules.Add("Entity", "Invalid Entity Id."); if (entityTypeToSave == null) saveBrokenRules.Add("Entity Type", "Invalid EntityType object."); else { if (string.IsNullOrEmpty(entityTypeToSave.EntityTypeValue)) saveBrokenRules.Add("Entity Type", "Value is Required."); } if (saveBrokenRules.Count() > 0) throw new BLLException("Validation rules Failed", saveBrokenRules); else return EntityTypeDAL.Save(entityId, entityTypeToSave); }
private static EntityType FillDataRecord(IDataRecord myDataRecord) { EntityType myObject = new EntityType(); myObject.EntityTypeId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("EntityTypeId")); myObject.EntityTypeValue = myDataRecord.GetString(myDataRecord.GetOrdinal("EntityTypeValue")); return myObject; }
public static int Save(int entityId, EntityType entityTypetoSave) { int result = 0; ExecuteTypeEnum queryId = ExecuteTypeEnum.InsertItem; //check for Valid Person - if existis, UPDATE else INSERT // 10 = INSERT_ITEM //20 = UPDATE_ITEM if (entityTypetoSave.EntityTypeId > 0) queryId = ExecuteTypeEnum.UpdateItem; using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("usp_ExecuteEntityType", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.AddWithValue("@QueryId", queryId); if (entityId > 0) myCommand.Parameters.AddWithValue("@EntityId", entityId); if (entityTypetoSave.EntityTypeId > 0) myCommand.Parameters.AddWithValue("@EntityTypeId", entityTypetoSave.EntityTypeId); if (entityTypetoSave.EntityTypeValue != null) myCommand.Parameters.AddWithValue("@EntityTypeName", entityTypetoSave.EntityTypeValue); //add return Output parameter to command object myCommand.Parameters.Add(HelperDAL.GetReturnParameterInt("returnValue")); myConnection.Open(); myCommand.ExecuteNonQuery(); //get return Value from stored Procedure and return ID result = (int)myCommand.Parameters["@returnValue"].Value; } myConnection.Close(); } return result; }
private EntityType HydrateEntityType(EntityTypeDTO entityTypeDTO) { EntityType tempItem = new EntityType(); if(entityTypeDTO != null) { tempItem.EntityTypeId = entityTypeDTO.EntityTypeId; if (!string.IsNullOrEmpty(entityTypeDTO.EntityTypeValue)) tempItem.EntityTypeValue = entityTypeDTO.EntityTypeValue; } return tempItem; }
private EntityTypeDTO HydrateEntityTypeDTO(EntityType entityType) { EntityTypeDTO tempItem = new EntityTypeDTO(); if(entityType != null) { tempItem.EntityTypeId = entityType.EntityTypeId; if (!string.IsNullOrEmpty(entityType.EntityTypeValue)) tempItem.EntityTypeValue = entityType.EntityTypeValue; } return tempItem; }