示例#1
0
        public IActionResult Delete(Pizza model)
        {
            Pizza pizza = pizzas.Get(model.ID);

            pizzas.Delete(pizza.ID);

            return(View("index"));
        }
 public IActionResult Delete(Pizza pizza)
 {
     if (ModelState.IsValid)
     {
         pizzas.Delete(pizza.ID);
         return(RedirectToAction("index"));
     }
     return(View());
 }
        private async Task InsertPizzas(IServiceScope scope)
        {
            var mysqlPizzaRepo = scope.ServiceProvider.GetRequiredService <Domain.Interfaces.Repositories.IPizzaRepository>();
            var pizzas         = await mysqlPizzaRepo.Get(x => x.Active);

            await _pizzaRepo.Delete();

            pizzas.ToList().ForEach(async(e) => await _pizzaRepo.Create(new PizzaCollection(e.Id, e.Name, e.Price, e.Active)));
        }
        public ResultEntity <Pizza> Delete(int id)
        {
            var pizza = new Pizza();

            try
            {
                pizza = _repository.GetById(id);

                if (pizza == null)
                {
                    return(ResultEntity <Pizza> .Fail(pizza, $"Pizza não existe"));
                }

                _repository.Delete(pizza);

                return(ResultEntity <Pizza> .Success(pizza));
            }
            catch (Exception e)
            {
                return(ResultEntity <Pizza> .Fail(pizza, $"Ocorreu algum erro na exclusão da pizza - {e.Message}"));
            }
        }
示例#5
0
        public DeletePizzaResponse DeletePizza(DeletePizzaRequest deletePizzaRequest)
        {
            DeletePizzaResponse result = new DeletePizzaResponse();

            try
            {
                Pizza pizza = _pizzaRepository.FindBy(deletePizzaRequest.Id);
                if (pizza != null)
                {
                    _pizzaRepository.Delete(pizza);
                }
                else
                {
                    GetStandardPizzaNotFoundException();
                }
            }
            catch (Exception ex)
            {
                result.StatusCode       = HttpStatusCode.InternalServerError;
                result.StatusDesciption = ex.Message;
            }

            return(result);
        }
 public IActionResult Delete(int Id, Pizza model)
 {
     pizzaRepository.Delete(Id);
     return(RedirectToAction("Index"));
 }
示例#7
0
 public IEnumerable <Pizza> Delete(int id)
 {
     _repository.Delete(id);
     return(_repository.GetAll());
 }
        public PizzaMutation(IPizzaRepository pizzaRepository)
        {
            Name = "PizzaMutations";

            Field <PizzaType>(
                "createPizza",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <PizzaInputType> > {
                Name = "pizza"
            }
                    ),
                resolve: context =>
            {
                dynamic pizzaInput        = context.Arguments["pizza"];
                string name               = pizzaInput["name"];
                List <object> toppingKeys = pizzaInput["toppings"];
                var pizza = new Pizza()
                {
                    Name          = name,
                    PizzaToppings = toppingKeys.Select(tk => new PizzaTopping()
                    {
                        ToppingId = (int)tk
                    }).ToList()
                };
                pizzaRepository.Add(pizza);
                return(this.loadPizza(pizza.Id, context, pizzaRepository));
            });

            Field <PizzaType>(
                "updatePizza",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <PizzaInputType> > {
                Name = "pizza"
            }
                    ),
                resolve: context =>
            {
                dynamic pizzaInput        = context.Arguments["pizza"];
                string name               = pizzaInput["name"];
                int id                    = pizzaInput["id"];
                List <object> toppingKeys = pizzaInput["toppings"];
                var pizza                 = new Pizza()
                {
                    Id            = id,
                    Name          = name,
                    PizzaToppings = toppingKeys.Select(tk => new PizzaTopping()
                    {
                        PizzaId   = id,
                        ToppingId = (int)tk
                    }).ToList()
                };
                pizzaRepository.Update(pizza);
                return(this.loadPizza(pizza.Id, context, pizzaRepository));
            });

            Field <StringGraphType>(
                "deletePizza",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id"
            }
                    ),
                resolve: context =>
            {
                int id = (int)context.Arguments["id"];
                pizzaRepository.Delete(id);
                return("OK");
            });
        }
示例#9
0
 public async Task DeletePizza(Guid id)
 {
     await _repository.Delete(id);
 }
示例#10
0
 public void DeletePizza(Pizza pizza)
 {
     _pizzaRepository.Delete(pizza);
 }
        public int RemovePizza(int id)
        {
            var removed = _pizzaRepository.Delete(id);

            return(removed);
        }
示例#12
0
 public IActionResult Delete(Pizza pizza)
 {
     pizzas.Delete(pizza.Id);
     return(RedirectToAction("Index"));
 }