Beispiel #1
0
        public JsonResult Create(CatchCreateModel model)
        {
            HttpCookie userCookie = Request.Cookies["User"];

            if (userCookie == null)
            {
                return(Json(new { data = false }, JsonRequestBehavior.AllowGet));
            }

            string userIdString = userCookie["UserId"];

            if (!Int32.TryParse(userIdString, out int userId))
            {
                return(Json(new { data = false }, JsonRequestBehavior.AllowGet));
            }

            _catchService.Create(model, userId);
            return(Json(new { data = true }, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        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);
        }