Beispiel #1
0
 public void Update(Player entity)
 {
     using (var context = new HangmanContext())
     {
         context.Entry(entity).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #2
0
        public Result <UserStatisticsDto> UpdateStatistics(int id, [NotNull] UserStatisticsDto model)
        {
            _logger.Information("UpdateStatistics requested by anonymous");
            try
            {
                var dbModel = _mapper.Map <UserStatisticsDb>(model);
                _context.UserStatistics.Attach(dbModel);
                var entry = _context.Entry(dbModel);
                entry.State = EntityState.Modified;

                _context.SaveChanges(); //UPDATE
                return(Result.Success(model));
            }
            catch (DbUpdateException ex)
            {
                _logger.Error("Connection to db is failed", ex);
                return(Result.Failure <UserStatisticsDto>(ex.Message));
            }
        }