コード例 #1
0
        public async Task Invoke(HttpContext context)
        {
            var request  = context.Request;
            var catchDto = new CatchDto
            {
                EventTime = DateTime.UtcNow,
                Method    = request.Method,
                PathBase  = request.PathBase
            };

            request.EnableRewind();
            using (StreamReader reader = new StreamReader(request.Body, Encoding.UTF8, true, 1024, true))
            {
                catchDto.Body = reader.ReadToEnd();
            }
            request.Body.Position = 0;

            var log = new UserLog
            {
                UserId = Guid.NewGuid(),
                Body   = catchDto.Serialize()
            };

            #pragma warning disable CS4014
            Task.Run(() => { ReportInfo(log); });
            #pragma warning restore CS4014

            await _next(context);
        }
コード例 #2
0
ファイル: CatchDao.cs プロジェクト: Mrotas/Hoof
        public void Insert(CatchDto catchDto)
        {
            var gameCatch = new Entities.Catch
            {
                HuntsmanId = catchDto.HuntsmanId,
                GameId     = catchDto.GameId,
                RegionId   = catchDto.RegionId,
                Date       = catchDto.Date,
                Count      = catchDto.Count
            };

            using (var db = new DbContext())
            {
                db.Catch.Add(gameCatch);
                db.SaveChanges();
            }
        }
コード例 #3
0
ファイル: CatchDao.cs プロジェクト: Mrotas/Hoof
        private IList <CatchDto> ToDtos(IList <Entities.Catch> entityList)
        {
            var dtos = new List <CatchDto>();

            foreach (Entities.Catch entity in entityList)
            {
                var dto = new CatchDto
                {
                    Id         = entity.Id,
                    HuntsmanId = entity.HuntsmanId,
                    GameId     = entity.GameId,
                    RegionId   = entity.RegionId,
                    Date       = entity.Date,
                    Count      = entity.Count
                };
                dtos.Add(dto);
            }
            return(dtos);
        }
コード例 #4
0
ファイル: CatchService.cs プロジェクト: Mrotas/Hoof
        public void Create(CatchCreateModel model, int userId)
        {
            GameDto game = _gameDao.Get(model.GameType, model.GameKind, model.GameSubKind).FirstOrDefault();

            if (game == null)
            {
                throw new Exception($"Could not find game by specified parameters: Type={model.GameType}, Kind={model.GameKind}, SubKind={model.GameSubKind}");
            }

            int regionId = _regionDao.GetRegionId(model.City, model.Circuit, model.District);

            UserDto user = _userDao.GetById(userId);

            var catchDto = new CatchDto
            {
                HuntsmanId = user.Id,
                GameId     = game.Id,
                RegionId   = regionId,
                Count      = model.Count,
                Date       = model.Date
            };

            _catchDao.Insert(catchDto);
        }