Пример #1
0
        public async Task <IActionResult> DeleteSprint([FromRoute] int productId, [FromRoute] int sprintId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var userId  = int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value);
            var product = await productService.GetProductById(productId);

            var sprintToUpdate = await sprintService.GetBacklogById(sprintId);

            if (product == null)
            {
                return(NotFound(new { message = "Product not found." }));
            }

            if (sprintToUpdate == null)
            {
                return(NotFound(new { message = "Sprint not found." }));
            }

            if (product.Owner.Id != userId)
            {
                return(Forbid());
            }

            await sprintService.DeleteSprint(sprintId);

            return(Ok());
        }
Пример #2
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         string productId  = collection.Get("productId");
         string idAsString = collection.Get("sprintId");
         _SprintService.DeleteSprint(Int32.Parse(idAsString));
         return(RedirectToAction("ListByStartDateDesc", new { productId = Int32.Parse(productId) }));
     }
     catch
     {
         return(View());
     }
 }