public int PostFoodCategory(FoodCategory foodCategory) { FoodCategoryDTO foodCategoryDto = Mapper.Map <FoodCategoryDTO>(foodCategory); int id = _repo.Post(foodCategoryDto); return(id); }
public FoodCategoryDTO GetFoodCategory(int id) { List <SqlParameter> sqlParams = new List <SqlParameter>(); sqlParams.Add("@id", SqlDbType.Int, (object)id); string sql = " SELECT FC_ID, FC_NAME "; sql += " FROM FoodCategories "; sql += " WHERE FC_ID = @id "; DataTable retTbl = m_DataAccess.FillTable(sql, sqlParams); if (retTbl.Rows.Count == 0) { return(null); } FoodCategoryDTO ret = new FoodCategoryDTO() { Id = (int)retTbl.Rows[0]["FC_ID"], Name = (string)retTbl.Rows[0]["FC_NAME"] }; return(ret); }
public FoodCategory GetFoodCategory(int id) { FoodCategoryDTO foodCategoryDto = _repo.GetFoodCategory(id); FoodCategory foodCategory = _mapper.Map <FoodCategory>(foodCategoryDto); return(foodCategory); }
public IActionResult CreateCategory(FoodCategoryClient reqObj) { if (reqObj == null) { BadRequest(); } JSONRetObj <int?> retObj = new JSONRetObj <int?>(); try { retObj.IsSuccess = true; retObj.Message = ""; FoodCategory foodCategory = Mapper.Map <FoodCategory>(reqObj); FoodCategoryDTO foodCategoryDto = Mapper.Map <FoodCategoryDTO>(foodCategory); int foodMarkerId = _repoFoodCategory.Post(foodCategoryDto); retObj.ResponseObj = foodMarkerId; } catch (Exception ex) { retObj.IsSuccess = false; retObj.Message = ex.Message; retObj.ResponseObj = null; } ViewData["RetObj"] = retObj; return(View("_Success")); }
public static FoodCategory Convert(FoodCategoryDTO obj) { return(new FoodCategory() { Id = obj.Id, Name = obj.Name, }); }
//POST public static Food Convert(FoodDTO obj) { var fc = new FoodCategoryDTO(obj.FoodCategoryName); return(new Food { Id = obj.Id, Name = obj.Name, Description = obj.Description //FoodCategory = Convert(fc), //TODO need to be check if it is needed ? //Price = Convert(new PriceDTO( obj.Price)) //TODO is this needed ? }); }
public List <FoodCategoryDTO> GetListCategory() { List <FoodCategoryDTO> listCategory = new List <FoodCategoryDTO>(); string query = "EXEC dbo.USP_GetListFoodCategory"; DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in data.Rows) { FoodCategoryDTO category = new FoodCategoryDTO(item); listCategory.Add(category); } return(listCategory); }
private void cbCategory_SelectedValueChanged(object sender, EventArgs e) { ComboBox cb = sender as ComboBox; if (cb.SelectedItem == null) { return; } FoodCategoryDTO selected = cb.SelectedItem as FoodCategoryDTO; LoadListFoodByIDCategory(selected.IdCategory.ToString()); }
public int Post(FoodCategoryDTO foodCategory) { using (SqlConnection conn = new SqlConnection(m_DataAccess.ConnectionString)) { conn.Open(); using (SqlCommand cmd = m_DataAccess.GetCommand("ADD_CATEGORY", CommandType.StoredProcedure, conn)) { cmd.Parameters.Add(m_DataAccess.BuildSqlParam("@name", SqlDbType.VarChar, foodCategory.Name)); cmd.Parameters.Add("@id", SqlDbType.Int).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); return((int)cmd.Parameters["@id"].Value); } } }
public void Update(FoodCategoryDTO foodCategory, int id) { throw new NotImplementedException(); }