Exemplo n.º 1
0
        public PlotMutation(PlotRepository plotRepo, CharacterRepository characterRepo)
        {
            Name = "PlotMutation";

            Field <PlotGraphType>("addOrModifyPlot",
                                  arguments: new QueryArguments(
                                      new QueryArgument <NonNullGraphType <PlotInputGraphType> > {
                Name = "plot", Description = "new or edited plot"
            }
                                      ),
                                  resolve: context => {
                var plot = context.GetArgument <Plot>("plot");
                if (plot.Id == 0)
                {
                    var dbPlot = plotRepo.Add(new Plot());
                    plot.Id    = dbPlot.Id;
                    plot       = ModifyPlot(plotRepo, characterRepo, plot);
                }
                else
                {
                    plot = ModifyPlot(plotRepo, characterRepo, plot);
                }
                return(plot);
            })
            .AddQAPermissions();
        }
Exemplo n.º 2
0
        public ActionResult Add(Plot plot)
        {
            if (ModelState.IsValid)
            {
                plot.UserId = User.Identity.GetUserId();
                _plotRepository.Add(plot);

                TempData["Message"] = "Plot was successfully added!";

                return(RedirectToAction("Index"));
            }

            return(View(plot));
        }