Exemple #1
0
        //[Authorize(Policy = "DeleteRolePolicy")]
        public async Task <IActionResult> Delete(string Id, int ids = 0)
        {
            int lvlRequestDecryptedId = Convert.ToInt32(protector.Unprotect(Id));

            try
            {
                await leaveRequestService.DeleteLeaveRequest(lvlRequestDecryptedId);

                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                ViewBag.ErrorMessage = $"The Leave Request cannot be deleted becouse of reference constraint of his/her Id in another database";
                return(View("CustomError"));
            }
        }
        public async Task <IActionResult> DeleteLeaveRequest(int id)
        {
            try
            {
                if (id != 0)
                {
                    var leaveRequest = await leaveRequestService.DeleteLeaveRequest(id);

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