コード例 #1
0
        public async Task <IActionResult> CreateNotification(NotificationCreateDto notificationCreateDto)
        {
            var notification = _mapper.Map <Notification>(notificationCreateDto);

            await _repository.CreateObjectAsync(notification);

            var notificationReadDto = _mapper.Map <NotificationReadDto>(notification);

            // https://docs.microsoft.com/en-us/dotnet/api/system.web.http.apicontroller.createdatroute?view=aspnetcore-2.2
            return(CreatedAtRoute(nameof(GetNotificationByDeviceId), new { Id = notificationReadDto.Id }, notificationReadDto));
        }
コード例 #2
0
        public async Task <IActionResult> CreateConstrain(AgreementCreateDto constrainCreateDto)
        {
            var constrain = _mapper.Map <Agreement>(constrainCreateDto);

            if (constrain != null)
            {
                await _repository.CreateObjectAsync(constrain);

                return(Ok(_mapper.Map <AgreementReadDto>(constrain)));
            }

            return(NotFound());
        }
コード例 #3
0
        public async Task <IActionResult> CreateRuuviStation(RuuviStationCreateDto ruuviStationCreateDto)
        {
            var station = _mapper.Map <RuuviStation>(ruuviStationCreateDto);

            station.Tags.ForEach(tag => tag.CreateDate = DateTime.UtcNow);
            station.Tags.ForEach(tag => tag.UpdateAt   = DateTime.UtcNow);
            station.Tags.ForEach(tag => tag.IsActive   = true);

            await _repository.CreateObjectAsync(station);

            var ruuviStationReadDto = _mapper.Map <RuuviStationReadDto>(station);

            // https://docs.microsoft.com/en-us/dotnet/api/system.web.http.apicontroller.createdatroute?view=aspnetcore-2.2
            return(CreatedAtRoute(nameof(GetRuuviStationByDeviceId), new { Id = ruuviStationReadDto.Id }, ruuviStationReadDto));
        }
コード例 #4
0
        public async Task <IActionResult> CreateRoute(RouteCreateDto routeCreateDto)
        {
            var route = _mapper.Map <Route>(routeCreateDto);

            if (route != null)
            {
                await _repository.CreateObjectAsync(route);

                var routeReadDto = _mapper.Map <RouteReadDto>(route);

                // https://docs.microsoft.com/en-us/dotnet/api/system.web.http.apicontroller.createdatroute?view=aspnetcore-2.2
                return(CreatedAtRoute(nameof(GetRouteById), new { Id = routeReadDto.Id }, routeReadDto));
            }

            return(NotFound());
        }