Example #1
0
        public Rate Create(Rate rate, User user)
        {
            rate.UserId = user.Id;
            rate.User   = user;
            rate.Total  = CalculateAverageOfCurrentRate(rate);

            _wrapperRepository.Rate.Create(rate);
            _wrapperRepository.Save();

            return(rate);
        }
Example #2
0
        public async Task PersistData(LilyPadData data)
        {
            data.RecordedAt = DateTime.Now;
            var dbData = Mapper.Map <Data>(data);
            await Repositories.Datas.Create(dbData);

            await Repositories.Save();
        }
Example #3
0
        public User CreateNewUser(string username, string password)
        {
            var hashedPassword = password.Hash();

            _wrapperRepository.Account.Create(
                new User {
                Name     = username,
                Password = hashedPassword
            }
                );
            _wrapperRepository.Save();

            return(_wrapperRepository.Account.GetUserByUsernameAndPassword(username, hashedPassword));
        }
Example #4
0
        public void UpdateScoreByGameId(int id)
        {
            var game        = _wrapperRepository.Game.GetGameById(id);
            var listOfRates = _wrapperRepository.Rate.GetListOfRatesByGameId(id);

            if (listOfRates != null)
            {
                game.Score = new Score {
                    Graphics  = (float)listOfRates.Average(item => item.Graphics),
                    Gameplay  = (float)listOfRates.Average(item => item.Gameplay),
                    Sound     = (float)listOfRates.Average(item => item.Sound),
                    Narrative = (float)listOfRates.Average(item => item.Narrative),
                    Total     = listOfRates.Average(item => item.Total)
                };
            }

            _wrapperRepository.Game.Update(game);
            _wrapperRepository.Save();
        }
Example #5
0
        public IActionResult CreatePerson(PersonDto personDto)
        {
            if (personDto == null)
            {
                return(BadRequest("Object is null"));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid model object"));
            }

            var person = _mapper.Map <Person>(personDto);

            _wrapperRepository.Person.Create(person);

            _wrapperRepository.Save();

            var createdPerson = _mapper.Map <PersonDto>(person);

            return(CreatedAtAction("PersonById", new { id = createdPerson.Id }, createdPerson));
        }