Exemplo n.º 1
0
        public async Task <IActionResult> GetPlotterByIdAsync([FromRoute] long id)
        {
            var plotter = await DbContext.Plotters.FirstOrDefaultAsync(x => x.Id == id);

            if (plotter == null)
            {
                return(NotFound());
            }

            var plotterInfo = PlotterService.GetPlotterInfo(plotter);

            return(Ok(plotterInfo));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CreatePlotterAsync([FromForm] string name)
        {
            if (!CustomizationOptions.AllowPlotterCreation)
            {
                return(NotFound());
            }

            long userId  = long.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier));
            var  plotter = new Plotter(name, userId);

            DbContext.Plotters.Add(plotter);
            await DbContext.SaveChangesAsync();

            var plotterInfo = PlotterService.GetPlotterInfo(plotter);
            var result      = new CreatePlotterResult(plotter.Token, plotterInfo);

            return(Ok(result));
        }