Пример #1
0
        public async Task <RouteModel> AddAsync(RouteFullModel model)
        {
            var entity = MapFromModel(model);

            entity.Name = entity.Name.PrepareRouteName();
            var result = await _routeRepository.AddAsync(entity);

            await SetProjectRoute(result.Id, model.ProjectId, null);

            return(MapToModel <RouteModel>(result));
        }
Пример #2
0
        public async Task <RouteModel> UpdateAsync(RouteFullModel model)
        {
            var entity = MapFromModel(model);

            entity.Name = entity.Name.PrepareRouteName();
            var result = await _routeRepository.UpdateAsync(entity);

            var projectRoute = await _projectRouteRepository.GetByRouteIdAsync(result.Id);

            await SetProjectRoute(result.Id, model.ProjectId, projectRoute);

            return(MapToModel <RouteModel>(result));
        }
Пример #3
0
        public async Task <RouteModel> Put(int id, [FromBody] RouteFullModel model)
        {
            var result = await _routeService.UpdateAsync(model);

            return(result);
        }
Пример #4
0
        public async Task <RouteModel> Post([FromBody] RouteFullModel model)
        {
            var result = await _routeService.AddAsync(model);

            return(result);
        }