public static NailService Parse(SqlDataReader reader) { var result = new NailService(); result.ID = (int)reader["id"]; result.Name = reader["name"] as string; result.Price = (Int16)reader["price"]; result.Duration = TimeSpan.FromMinutes((Int16)reader["duration"]); result.Abbreviation = reader["abbreviation"] as string; result.IsObsolete = (bool)reader["isObsolete"]; return(result); }
public List <NailService> GetAvailableServices() { string query = "select * from Services where isObsolete = 'False' order by pos"; var services = new List <NailService>(); using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbConnectionSctring"].ConnectionString)) using (SqlCommand cmd = new SqlCommand(query, cn)) { cn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { services.Add(NailService.Parse(dr)); } cn.Close(); } return(services); }
public List <NailService> GetSelectedServicesForDate(int nailDateID) { string query = "select id,name,price,duration,abbreviation,isObsolete from Services,(SELECT serviceId FROM dbo.NailDateService where nailDateId = @ID) as t where t.serviceId = id"; var services = new List <NailService>(); using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbConnectionSctring"].ConnectionString)) using (SqlCommand cmd = new SqlCommand(query, cn)) { cmd.Parameters.Add("@ID", SqlDbType.Int).Value = nailDateID; cn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { services.Add(NailService.Parse(dr)); } cn.Close(); } return(services); }