Beispiel #1
0
        public IActionResult Delete(int id)
        {
            var objFromDb = _systemService.Get(id);

            if (objFromDb == null)
            {
                return(Json(new { success = false, message = "Błąd przy usuwaniu" }));
            }
            _systemService.Delete(id);
            return(Json(new { success = true, message = "Usunięto" }));
        }
Beispiel #2
0
        public ActionResult Delete(int id)
        {
            var system = _systemService.Get(u => u.Id == id).First();

            if (null == system)
            {
                return(NotFound(new { error = "System not found" }));
            }
            try {
                _systemService.Delete(system);
            } catch {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Cannot delete system"));
            }
            return(Ok());
        }
        public async Task <ActionResult <bool> > Delete(int id)
        {
            try
            {
                await _systemService.Delete(id);

                return(Ok(true));
            }
            catch (ArgumentOutOfRangeException)
            {
                return(BadRequest($"System with id {id} does not exists"));
            }
            catch (Exception)
            {
                return(BadRequest($"Failed to delete {id}"));
            }
        }
        public ActionResult Save(Menu menu)
        {
            if (menu != null && menu.MenuId > 0)
            {
                String msg = String.Format("Menu Object:ID={0} Name={1} Url={2} Status={3} IsLeaf={4}",
                                           menu.MenuId, menu.MenuName, menu.Url, menu.Status, menu.IsLeaf);
                LogHelper.Log(LogLevel.Error, msg);
                bool flag = systemService.Save(menu);
                if (flag)
                {
                    return(Success(null, "处理成功", 1));
                }
                else
                {
                    return(Error(null, "处理失败"));
                }
            }
            else
            {
                string act = Request["oper"];
                Int32  id  = Request["id"] != null?Convert.ToInt32(Request["id"]) : 0;

                Int32 result = 0;
                if (act == "del")
                {
                    result = systemService.Delete(id);
                }

                if (result > 0)
                {
                    return(Success(null, "删除成功"));
                }
                else
                {
                    return(Error(null, "删除失败"));
                }
            }
        }