Beispiel #1
0
 public static SkinRecordModel Convert(SkinRecord skin)
 {
     return(new SkinRecordModel()
     {
         Id = skin.Id,
         GameProfileId = skin.GameProfileId,
         GunId = skin.GunId,
         StatusCode = skin.StatusCode
     });
 }
        public async Task <ActionResult> PostSkinRecord(
            [FromBody] SkinRecord skin)
        {
            _logger.LogInformation("POST /api/skins API call SkinRecordVM: ", skin);

            SkinRecordModel newEntity = Convert(skin);

            var existingEntity = await _context.SkinRecords.FindAsync(newEntity.Id);

            if (existingEntity == null)
            {
                await _context.SkinRecords.AddAsync(newEntity);
            }
            else
            {
                existingEntity.StatusCode = newEntity.StatusCode;
            }
            var response = await _context.SaveChangesAsync();

            _logger.LogInformation("DB entries saved: ", response);
            return(NoContent());
        }