public static CategoryDto GetCategory(int id) { Category category = CategoryDal.GetCategory(id); CategoryDto dtoCategory = new CategoryDto(category); //converting Dal Object to Dto return(dtoCategory); }
public Category GetCategory(int id) { var categoryDal = new CategoryDal(); var dt = categoryDal.GetCategory(id); var category = new Category(); if (dt.Rows.Count <= 0) { return(null); } var dr = dt.Rows[0]; category.Id = int.Parse(dr["Id"].ToString()); category.Name = dr["Name"].ToString(); return(category); }