private static void AddCommonParams(SpecificationAddRequest model, SqlParameterCollection col) { col.AddWithValue("@Frame", model.Frame); col.AddWithValue("@Fork", model.Fork); col.AddWithValue("@Wheelset", model.Wheelset); col.AddWithValue("@FrontHub", model.FrontHub); col.AddWithValue("@RearHub", model.RearHub); col.AddWithValue("@RimFront", model.RimFront); col.AddWithValue("@RimRear", model.RimRear); col.AddWithValue("@TireFront", model.TireFront); col.AddWithValue("@TireRear", model.TireRear); col.AddWithValue("@Tires", model.Tires); col.AddWithValue("@Shifters", model.Shifters); col.AddWithValue("@FrontDerailleur", model.FrontDerailleur); col.AddWithValue("@RearDerailleur", model.RearDerailleur); col.AddWithValue("@Crankset", model.Crankset); col.AddWithValue("@BottomBracket", model.BottomBracket); col.AddWithValue("@Cassette", model.Cassette); col.AddWithValue("@Chain", model.Chain); col.AddWithValue("@Pedals", model.Pedals); col.AddWithValue("@Saddle", model.Saddle); col.AddWithValue("@Seatpost", model.Seatpost); col.AddWithValue("@Handlebar", model.Handlebar); col.AddWithValue("@Grips", model.Grips); col.AddWithValue("@Stem", model.Stem); col.AddWithValue("@Headset", model.Headset); col.AddWithValue("@Brakeset", model.Brakeset); col.AddWithValue("@Weight", model.Weight); col.AddWithValue("@WeightLimit", model.WeightLimit); }
public int Add(SpecificationAddRequest model, int productId, int userId) { int id = 0; string procName = "[dbo].[Specification_Insert]"; _data.ExecuteNonQuery(procName, inputParamMapper : delegate(SqlParameterCollection col) { col.AddWithValue("@ProductId", productId); col.AddWithValue("@CreatedBy", userId); AddCommonParams(model, col); SqlParameter idOut = new SqlParameter("@Id", SqlDbType.Int); idOut.Direction = System.Data.ParameterDirection.Output; col.Add(idOut); }, returnParameters : delegate(SqlParameterCollection returnCollection) { object oId = returnCollection["@Id"].Value; Int32.TryParse(oId.ToString(), out id); }); return(id); }