示例#1
0
        public async Task <IActionResult> Delete([FromRoute] Guid id)
        {
            var result = await _plansService.RemoveAsync(id);

            if (!result.Success)
            {
                return(BadRequest(result));
            }

            return(Ok(result));
        }
        public async Task <ActionResult> Delete(int id)
        {
            var plan = await _plansService.GetByIdAsync(id);

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

            if (plan.Active)
            {
                ModelState.AddModelError("endDate", "方案上架中無法刪除");
                return(BadRequest(ModelState));
            }

            plan.SetUpdated(CurrentUserId);
            await _plansService.RemoveAsync(plan);

            return(Ok());
        }