Example #1
0
        public async Task Invoke(HttpContext context, IRequestRepo requestRepo, IAuxUserAgentService userAgentService)
        {
            //getting user agent from header
            StringValues user_agent = "";

            context.Request.Headers.TryGetValue("User-Agent", out user_agent);


            //waiting for user agent
            // var result = await userAgentService.ParseUserAgentData(user_agent.ToString());

            //saving request(request+useragentdata) data to dbcontext
            requestRepo.Add(new Request
            {
                Source      = context.Connection.RemoteIpAddress.ToString() + ":" + context.Connection.RemotePort.ToString(),
                Destination = context.Request.Path.ToString(),
                Method      = context.Request.Method,
                //UserAgent = result,
            });

            //save changes to db
            await requestRepo.SaveChangesAsync();

            //calling next to go to next middleware
            await _next(context);
        }
Example #2
0
        public IActionResult Create([FromBody] Request model)
        {
            if (model == null || !ModelState.IsValid)
            {
                return(BadRequest());
            }

            _repo.Add(model);
            return(CreatedAtAction("Create", model));
        }
        public Request Add(int BloodTypeId, UrgencyEnum urgency, int CityId, string RequestUserId, DateTime date, int QuantityP, int QuantityR, int QuantityT, int ProfileId)
        {
            Request p = new Request()
            {
                BloodTypeId   = BloodTypeId,
                Urgency       = urgency,
                CityId        = CityId,
                AspNetUsersId = RequestUserId,
                Date          = date,
                QuantityP     = QuantityP,
                QuantityR     = QuantityR,
                QuantityT     = QuantityT,
                ProfileId     = ProfileId,
                Completed     = false
            };

            Repository.Add(p);

            return(p);
        }