Beispiel #1
0
        public async Task <IActionResult> PutAssetNotes(long id, AssetNotes assetNotes)
        {
            if (id != assetNotes.IdNote)
            {
                return(BadRequest());
            }

            _context.Entry(assetNotes).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AssetNotesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #2
0
        public async Task <ActionResult <AssetNotes> > PostAssetNotes(AssetNotes assetNotes)
        {
            assetNotes.Asset     = _context.Assets.First <Asset>(x => x.AssetId == assetNotes.Asset.AssetId);
            assetNotes.CreatedBy = _context.Users.First <User>(x => x.Id == assetNotes.CreatedBy.Id);

            assetNotes.CreationDate = DateTime.UtcNow;
            _context.AssetNotes.Add(assetNotes);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAssetNotes", new { id = assetNotes.IdNote }, assetNotes));
        }