コード例 #1
0
        public IHttpActionResult Create(StartTrace startTrace)
        {
            if (startTrace.Minutes < 1)
            {
                return(BadRequest("Tracking must be enabled for one minute at least."));
            }

            if (startTrace.Minutes > 10)
            {
                return(BadRequest("Tracking can only be enabled for ten minutes at most."));
            }

            var traceConfiguration = new TraceConfiguration
            {
                StartDate = DateTime.UtcNow,
                EndDate   = DateTime.UtcNow.AddMinutes(startTrace.Minutes),
                LinkId    = startTrace.LinkId
            };

            _traceRepository.Create(traceConfiguration);

            // TODO: Location
            return(Created("", traceConfiguration));
        }