Ejemplo n.º 1
0
        public async Task <ActionResult> Delete(int id)
        {
            var lot = await _lotService.GetByIdAsync(id);

            if (lot is null)
            {
                return(RedirectToAction("NotFound", "Errors"));
            }

            if ((!User.IsInRole("Admin") &&
                 User.Identity.GetUserId() != lot.SellerId) ||
                !string.IsNullOrWhiteSpace(lot.BuyerId))
            {
                return(RedirectToAction("Forbidden", "Errors"));
            }

            await _lotService.DeleteByIdAsync(id);

            return(RedirectToAction("ActiveLots", "Lots"));
        }