public bool DeletePassengerAndTicket(PassengerAndTicketDto model) { try { var param = new SqlParameter[8]; param[0] = new SqlParameter("@Id", model.Id); param[1] = new SqlParameter("@ToCityId", 0); param[2] = new SqlParameter("@FromCityId", 0); param[3] = new SqlParameter("@UserId", 0); param[4] = new SqlParameter("@TotalCount", 0); param[5] = new SqlParameter("@CreatedDate", DateTime.Now); param[6] = new SqlParameter("@CompanyId", 0); param[7] = new SqlParameter("@OperationType", "DEL"); var cmd = new SqlCommand("prdPassengerAndTicket", new SqlConnection(connStr)); cmd.CommandType = CommandType.StoredProcedure; for (int i = 0; i < param.Length; i++) { cmd.Parameters.Add(param[i]); } cmd.CommandTimeout = (1000 * 60 * 10); cmd.ExecuteNonQuery(); return(true); } catch (Exception ex) { return(false); } }
public int InsertPassengerAndTicket(PassengerAndTicketDto model) { try { var operationType = model.Id > 0 ? "UPD" : "INS"; var cn = new SqlConnection(connStr); var cmd = new SqlCommand("prdPassengerAndTicket", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", model.Id); cmd.Parameters.AddWithValue("@ToCityId", model.ToCityId); cmd.Parameters.AddWithValue("@FromCityId", model.FromCityId); cmd.Parameters.AddWithValue("@UserId", model.UserId); cmd.Parameters.AddWithValue("@TotalCount", model.TotalCount); cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now); cmd.Parameters.AddWithValue("@CompanyId", model.CompanyId); cmd.Parameters.AddWithValue("@OperationType", operationType); cn.Open(); var result = Convert.ToInt32(cmd.ExecuteScalar()); cn.Close(); return(result); } catch (Exception ex) { return(0); } }