コード例 #1
0
        public int PostFoodCategory(FoodCategory foodCategory)
        {
            FoodCategoryDTO foodCategoryDto = Mapper.Map <FoodCategoryDTO>(foodCategory);
            int             id = _repo.Post(foodCategoryDto);

            return(id);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public FoodCategory GetFoodCategory(int id)
        {
            FoodCategoryDTO foodCategoryDto = _repo.GetFoodCategory(id);
            FoodCategory    foodCategory    = _mapper.Map <FoodCategory>(foodCategoryDto);

            return(foodCategory);
        }
コード例 #4
0
        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"));
        }
コード例 #5
0
 public static FoodCategory Convert(FoodCategoryDTO obj)
 {
     return(new FoodCategory()
     {
         Id = obj.Id,
         Name = obj.Name,
     });
 }
コード例 #6
0
        //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 ?
            });
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: fManager.cs プロジェクト: MaxV-LTTVinh/CoffeShop
        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());
        }
コード例 #9
0
        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);
                }
            }
        }
コード例 #10
0
 public void Update(FoodCategoryDTO foodCategory, int id)
 {
     throw new NotImplementedException();
 }