Beispiel #1
0
        public async Task <DataAPIResult <MenuInfoDTO> > Add(MenuInfo menu)
        {
            var result = new DataAPIResult <MenuInfoDTO>();

            result = await service.Add(menu);

            return(result);
        }
Beispiel #2
0
        public ActionResult Create(Menus menus, MenuInfo menuInfo, HttpPostedFileBase uploadfile)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var listTypes = _generalFunctions.GetListType("Menü Yeri");
                    var model     = new MenusVM
                    {
                        Menus    = new Menus(),
                        MenuInfo = new MenuInfo(),
                        ListType = listTypes
                    };
                    model.Menus.Active = true;
                    model.Menus.Sort   = 1;
                }

                menus.CreationDate = DateTime.Now;
                if (uploadfile != null)
                {
                    menus.Image = uploadfile.FileName;
                }
                else
                {
                    menus.Image = null;
                }

                _menusService.Add(menus);
                int menuID = menus.MenuID;

                //Menüyü resmini kayıt edelim.
                if (menus.Image != null && uploadfile != null)
                {
                    _generalFunctions.CreateDirectory(HttpContext.Server.MapPath("/Uploads/Menus/"), menuID.ToString());
                    uploadfile.SaveAs(HttpContext.Server.MapPath("/Uploads/Menus/" + menuID + "/" + uploadfile.FileName));
                }


                //Menü bilgilerini kayıt edelim.
                menuInfo.MenuID     = menuID;
                menuInfo.LanguageID = 1;
                _menuInfoService.Add(menuInfo);

                TempData.Add("message", "Menü başarıyla eklendi.");

                return(RedirectToAction("index"));
            }
            catch (Exception ex)
            {
                TempData.Add("message", "Menü kayıt işleminde hata ile karşılaştı. Hata: " + ex.Message);
                return(View());
            }
        }
        public async Task <IActionResult> AddMenuInfo(MenuInfo menuInfo)
        {
            menuInfo.MenuInfoId = Guid.NewGuid().ToString();
            menuInfo.SetTime    = DateTime.Now;


            // var res = _EFCoreService.AddMenuInfo(menuInfo);
            var res = await _menuInfoService.Add(menuInfo);

            return(new JsonResult(new Result {
                Data = res, Msg = "成功添加菜单信息", Status = 200
            }));
        }