Exemplo n.º 1
0
        public async Task <TraceDto> CreateTraceAsync(CreateTraceDto createTraceDto)
        {
            Check.NotNull(createTraceDto, nameof(createTraceDto));

            if (string.IsNullOrWhiteSpace(createTraceDto.Title) ||
                createTraceDto.DueDate < LocalDate.FromDateTime(DateTime.Today))
            {
                throw new BusinessValidationException(TextConstants.CreateTraceWithoutTitleOrFutureDateErrorMessage);
            }

            var trace = new Trace
            {
                Description   = createTraceDto.Description.ValueOrDefault(),
                State         = TraceState.Active,
                Title         = createTraceDto.Title,
                DueDate       = createTraceDto.DueDate,
                PropertyId    = createTraceDto.PropertyId,
                ReservationId = createTraceDto.ReservationId.ValueOrDefault(),
                AssignedRole  = createTraceDto.AssignedRole.ValueOrDefault()
            };

            _traceRepository.Insert(trace);

            await _traceRepository.SaveAsync();

            return(TraceToDto(trace));
        }
Exemplo n.º 2
0
        public string Post([FromBody] Trace model)
        {
            if (model != null)
            {
                var appId = HttpContext.Request.Headers.First(h => h.Key == "appid")
                            .Value.ToArray()[0];
                model.AppId = appId;
                model.Time  = DateTime.Now;
                _traceRepository.Insert(model);

                _websocketService.SendToAll(JsonConvert.SerializeObject(model));
            }

            return("ok");
        }