Ejemplo n.º 1
0
        public override async Task GetCurfews(CurfewRequest request, IServerStreamWriter <Curfew> responseStream, ServerCallContext context)
        {
            var curfews = await GetCurfewsAsync(request.Login);

            foreach (var cf in curfews)
            {
                await responseStream.WriteAsync(cf);
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> DetectAge([FromBody] FaceViewModel model)
        {
            var faceAttributes = await _faceService.DetectFaceAttributesAsync(model.ImageData,
                                                                              FaceAttributeType.Age);

            var nowInTurkey = DateTime.UtcNow.AddHours(3);

            var curfewResult = new CurfewResult {
                Age = faceAttributes?.Age
            };
            var curfewRequest = new CurfewRequest(curfewResult.Age ?? 0, nowInTurkey.DayOfWeek, nowInTurkey.Hour);

            curfewResult.IsFree = _curfewService.IsFreeToGoOut(curfewRequest);

            return(Ok(curfewResult));
        }
Ejemplo n.º 3
0
        public bool IsFreeToGoOut(CurfewRequest curfewRequest)
        {
            if (curfewRequest.IsWeekend() &&
                curfewRequest.IsOutsideOfHours(10, 20))
            {
                return(false);
            }

            if (curfewRequest.IsUnder20())
            {
                return(curfewRequest.IsBetweenHours(13, 16));
            }

            if (curfewRequest.IsOver64())
            {
                return(curfewRequest.IsBetweenHours(10, 13));
            }

            return(true);
        }
Ejemplo n.º 4
0
 public CurfewServiceStepDefinitions()
 {
     _curfewRequest = new CurfewRequest();
 }