// GET: Category/Edit/{id} public ActionResult Edit(int id) { LOGGER.Info("CategoryController::Edit GET"); //Category category = new Category //{ // Id = 1, // Name = "JavaScript" //}; Category category = categoryDao.GetCategory(id); return(View(category)); }
public IEnumerable <Product> GetAllProducts() { _logger.Info($"DAL.{nameof(ProductDao)}.{nameof(GetAllProducts)}: Getting all products"); using (SqlConnection connection = new SqlConnection(_connectionString)) { SqlCommand command = new SqlCommand("dbo.Product_GetAllProducts", connection) { CommandType = System.Data.CommandType.StoredProcedure }; SqlDataReader reader; try { connection.Open(); reader = command.ExecuteReader(); _logger.Info($"DAL.{nameof(ProductDao)}.{nameof(GetAllProducts)}: Connected to database"); } catch (InvalidOperationException ex) { _logger.Error($"DAL.{nameof(ProductDao)}.{nameof(GetAllProducts)}: Not connected to database: " + ex.Message); throw new SystemException("Connection error", ex); } int?CategoryID; while (reader.Read()) { CategoryID = (int?)reader["CategoryID"]; yield return(new Product( (int?)reader["Id"], (string)reader["Name"], (string)reader["Image"], (string)reader["Description"], CategoryID is null ? null : _categoryDao.GetCategory(CategoryID ?? -1))); } } _logger.Info($"DAL.{nameof(ProductDao)}.{nameof(GetAllProducts)}: All products received"); yield break; }
public Category GetCategory(string categoryId) { Category category = null; category = _categoryDao.GetCategory(categoryId); return(category); }
public Category GetCategoryOrNull(int id) { _logger.Info($"BLL.{nameof(CategoryBll)}.{nameof(GetCategoryOrNull)}: Getting the category id = " + id); if (_categoryDao.IsCategory(id)) { _logger.Info($"BLL.{nameof(CategoryBll)}.{nameof(GetCategoryOrNull)}: Category id = {id} received"); return(_categoryDao.GetCategory(id)); } else { _logger.Warn($"BLL.{nameof(CategoryBll)}.{nameof(GetCategoryOrNull)}: Category id = {id} not found"); return(null); } }
public Category GetCategory(string name) { return(categoryDao.GetCategory(name)); }
public string GetCategoryName(int categoryId) { int statusId = statusDao.GetStatus(Status.VALUE.CATEGORY_ACTIVE.ToString()).Id; return(categoryDao.GetCategory(categoryId, statusId).Name); }
public CategoryModel GetCategory(int id) { Category category = _iCategoryDao.GetCategory(id); return(CategoryConverter.ConvertToModel(category)); }