コード例 #1
0
        public async Task <MenuCategory> Add(MenuCategory model)
        {
            var entity = _menuCategoryRepository.Add(model);
            await _menuCategoryRepository.SaveChangeAsync();

            return(model);
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "Id,NameCategory,Comment")] MenuCategory menuCategory, HttpPostedFileBase uploadedFile)
        {
            if (ModelState.IsValid)
            {
                string directory = Server.MapPath(Url.Content("~/Content/Images"));
                menuCategory.Photo = ImageFiles.AddFile(directory, uploadedFile);

                menuCategoryRepository.Add(menuCategory);
                return(RedirectToAction("Index"));
            }
            return(View(menuCategory));
        }