示例#1
0
        public async Task <IActionResult> Update(long id)
        {
            try
            {
                ViewData["listMenu"] = await _menuManager.Get_List_Menu();

                var data = await _menuManager.Find_By_Id(id);

                return(PartialView("_Update", data));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, Message = ex.Message }));
            }
        }
示例#2
0
        public async Task <IActionResult> Update([FromBody] Menus inputModel)
        {
            try
            {
                var data = await _menuManager.Find_By_Id(inputModel.Id);

                if (data == null)
                {
                    throw new Exception($"{MessageConst.DATA_NOT_FOUND}");
                }

                var exist = await _menuManager.Find_By_Name(inputModel.Name);

                inputModel.CreatedDate = data.CreatedDate;
                inputModel.UpdatedDate = DateTime.Now;
                await _menuManager.Update(inputModel);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }