Ejemplo n.º 1
0
        public async Task <IActionResult> Delete(string id)
        {
            string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            var getOld = await _plansService.GetPlanById(id, userId);

            if (getOld == null)
            {
                return(NotFound());
            }

            // Remove the file
            //string fullPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", getOld.CoverPath.Replace(_configuration["AppUrl"], ""));
            //System.IO.File.Delete(fullPath);

            var deletedPlan = await _plansService.DeletePlanAsync(id, userId);

            return(Ok(new OperationResponse <Plan>
            {
                IsSuccess = true,
                Message = $"{getOld.Title} has been deleted successfully!",
                Record = deletedPlan
            }));
        }