Exemplo n.º 1
0
        public IActionResult Delete(int id)
        {
            try
            {
                _dishService.DeleteDish(id);

                string currentEmail = this.User.FindFirst(ClaimTypes.Name).Value;
                string userId       = _userHelper.GetUserId(currentEmail);

                if (userId == null)
                {
                    return(NotFound("User not found"));
                }

                _logger.LogInformation($"[{DateTime.Now.ToString()}]:[dish/delete/{id}]:[info:delete dish {id}]:[user:{userId}]");

                return(Ok(id));
            }
            catch (ValidationException ex)
            {
                _logger.LogError($"[{DateTime.Now.ToString()}]:[dish/delete/{id}]:[error:{ex.Property}, {ex.Message}]");

                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                _logger.LogError($"[{DateTime.Now.ToString()}]:[dish/delete/{id}]:[error:{ex}]");

                return(BadRequest());
            }
        }
        public IActionResult DeleteConfirmed(int id)
        {
            var x = _service.GetDishById(id);

            _service.DeleteDish(x);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            dishService.DeleteDish(id);
            var dishes = dishService.GetDishes();

            return(PartialView("DishList", dishes));
        }
Exemplo n.º 4
0
 public ActionResult <bool> DeleteDish(int id, int restaurantId)
 {
     try
     {
         return(Ok(dishService.DeleteDish(restaurantId, id)));
     }
     catch
     {
         throw new Exception("Not possible to show");
     }
 }
Exemplo n.º 5
0
        public IActionResult DeleteDish(int id)
        {
            _requestLogService.SaveRequest(User.Identity.GetUserId(), "DELETE", "api/v1/dishes/{id}", "DeleteDish");
            var dishDTO = _dishService.GetDishById(id);

            if (dishDTO == null)
            {
                return(NotFound());
            }
            if (!IsRestaurantUserOrAdmin(dishDTO.RestaurantId))
            {
                return(StatusCode(403, "Dish can only be deleted by admin or by restaurant user"));
            }
            _dishService.DeleteDish(id);
            return(NoContent());
        }
        public IActionResult Delete(int?id, int catalogId, string searchSelectionString, string name)
        {
            try
            {
                _dishService.DeleteDish(id);

                string currentUserId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;
                _logger.LogInformation($"{DateTime.Now.ToString()}: User {currentUserId} deleted dish {id}");

                return(RedirectToAction("Index", new { catalogId, searchSelectionString, name }));
            }
            catch (ValidationException ex)
            {
                _logger.LogError($"{DateTime.Now.ToString()}: {ex.Property}, {ex.Message}");
                return(Content(ex.Message));
            }
        }
Exemplo n.º 7
0
        public IActionResult DeleteDish(Guid id, [FromBody] DishPlDto dish)
        {
            if (!ModelState.IsValid)
            {
                return(StatusCode(400, "Model is not valid"));
            }

            try
            {
                dish.DishId = id;
                var newDish = mapper.Map <BlDto_Dish>(dish);
                dishService.DeleteDish(newDish);
                return(StatusCode(204, "Dish was deleted"));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, "Internal server error. Dish is not deleted. Exception message: " + ex));
            }
        }
Exemplo n.º 8
0
 public ActionResult Delete([FromRoute] int restaurantId, int dishId)
 {
     _dishService.DeleteDish(restaurantId, dishId);
     return(NoContent());
 }
Exemplo n.º 9
0
 public async Task Delete(int id)
 {
     await m_dishService.DeleteDish(id);
 }
Exemplo n.º 10
0
        public async Task <IActionResult> Delete(int id)
        {
            await _service.DeleteDish(id);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 11
0
 public HttpResponseMessage Delete(int dishId = 2)
 {
     _dishService.DeleteDish(dishId);
     return(Request.CreateResponse(HttpStatusCode.OK));
 }