Example #1
0
        public ActionResult DeleteLevel(int levelId)
        {
            var deleteLvl = _levelService.GetById(levelId);

            if (deleteLvl == null)
            {
                return(NotFound(new { message = "Can't delete. Level not found" }));
            }
            _levelService.DeleteLevel(levelId);
            return(NoContent());
        }
Example #2
0
        //[Authorize(Policy = "DeleteRolePolicy")]
        public async Task <IActionResult> Delete(string Id, int Ids = 0)
        {
            int lvlDecryptedId = Convert.ToInt32(protector.Unprotect(Id));

            try
            {
                await levelService.DeleteLevel(lvlDecryptedId);

                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                ViewBag.ErrorMessage = $"The Employee Level cannot be deleted becouse of reference constraint of his/her Id in another database";
                return(View("CustomError"));
            }
        }
Example #3
0
        public async Task <IActionResult> DeleteLevel(int id)
        {
            try
            {
                if (id != 0)
                {
                    var level = await levelService.DeleteLevel(id);

                    return(Ok(level));
                }
                return(BadRequest());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }