public IHttpActionResult Delete(int id)
        {
            ApiResData res = new ApiResData();

            try
            {
                if (!ModelState.IsValid)
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                    resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Delete, new Exception(eFunc.fg.DataNf)));
                    return(Content(HttpStatusCode.NotFound, resObj));
                }

                rs = repo.Delete(id, "System", CurrentUser.GetCurrentDateTime());
                if (rs.IsSuccess)
                {
                    rs.SetSuccessStatus();
                }
                else
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                }

                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Delete, null));
                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Delete, new Exception(eFunc.fg.DFailed)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }
        public IActionResult Delete(int id)
        {
            var deletedSubCategory = subCatrepo.Delete(id);

            if (deletedSubCategory != null)
            {
            }
            else
            {
            }
            return(RedirectToAction(nameof(Index)));
        }
示例#3
0
        public async Task <ActionResult <Category> > DeleteSubCategory(int id)
        {
            var subCategory = await _repo.GetById(id);

            if (subCategory == null)
            {
                return(NotFound());
            }
            await _repo.Delete(id);

            if (await _repo.SaveAll())
            {
                return(Ok("Deleted"));
            }
            else
            {
                return(BadRequest("Could not be deleted"));
            }
        }