Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> AddRoute(Route entity)
        {
            entity.id = Guid.NewGuid();
            var response = await rService.AddAsync(entity);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Create(RouteDTO routeDTO)
        {
            var mapPoint = routeDTO.ToEntity();

            if (!mapPoint.IsValid)
            {
                return(BadRequest(mapPoint.ValidationResult));
            }

            await _routeService.AddAsync(mapPoint);

            return(base.CreatedAtAction("Get", new { Id = mapPoint.Id }, new RouteDTO(mapPoint)));
        }
Ejemplo n.º 3
0
        public async Task ShouldCreateEntry()
        {
            var route = new Route(Guid.NewGuid(), Guid.NewGuid(), 10, 10);
            await _service.AddAsync(route);

            Assert.NotEqual(Guid.Empty, route.Id);

            var fetchedRoute = await _service.GetByIdAsync(route.Id);

            Assert.Equal(route.FromId, fetchedRoute.FromId);
            Assert.Equal(route.ToId, fetchedRoute.ToId);

            _routeId = fetchedRoute.Id;
        }
        public async Task <ActionResult> Add(AddRouteModel model)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest());
            }

            //TODO get user Id
            //var userName = httpContextAccessor.HttpContext.User.Identity.Name;
            var author = await authorService.GetByUserId(userId);

            var route = await routeService.AddAsync(author.Id, model);

            return(Ok(route.Id));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create(RouteEditViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var busStation = new RouteModel
            {
                RouteName = viewModel.RouteName,
                RouteCode = viewModel.RouteCode
            };

            await _routeService.AddAsync(busStation);

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 6
0
        public async Task <RouteModel> Post([FromBody] RouteFullModel model)
        {
            var result = await _routeService.AddAsync(model);

            return(result);
        }