public int AddCropPerticular(CropPerticularModel model) { int id = 0; try { using (var conn = new SqlConnection(ContexDetails.Connectiondetails())) { conn.Open(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = "sp_AddCropPerticular"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CropId", model.CropId); cmd.Parameters.AddWithValue("@Transportation", model.Transportation); cmd.Parameters.AddWithValue("@LabourCharges", model.LabourCharges); cmd.Parameters.AddWithValue("@Loading", model.Loading); cmd.Parameters.AddWithValue("@Gunnies", model.Gunnies); cmd.Parameters.AddWithValue("@OtherCharges", model.OtherCharges); cmd.Parameters.AddWithValue("@UserId", model.CreatedBy); cmd.ExecuteNonQuery(); id = 1; } conn.Close(); } } catch (Exception ex) { throw ex; } return(id); }
public CropPerticularModel GetCropPerticular(CropPerticularModel request) { CropPerticularModel model = new CropPerticularModel(); try { using (var conn = new SqlConnection(ContexDetails.Connectiondetails())) { conn.Open(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = "sp_GetCropPerticularDetails"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserId", request.CreatedBy); cmd.Parameters.AddWithValue("@CropId", request.CropId); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { model.Id = Convert.ToInt32(reader["Id"]); model.CropId = Convert.ToInt32(reader["CropId"]); model.Transportation = Convert.ToString(reader["Transportation"]); model.LabourCharges = Convert.ToString(reader["LabourCharges"]); model.Loading = Convert.ToString(reader["Loading"]); model.Gunnies = Convert.ToString(reader["Gunnies"]); model.OtherCharges = Convert.ToString(reader["OtherCharges"]); model.CropName = Convert.ToString(reader["CropName"]); model.Catagory = Convert.ToString(reader["Catagory"]); } } } conn.Close(); } } catch (Exception ex) { throw ex; } return(model); }