Exemple #1
0
        public async Task <IActionResult> PatchDescriptorEntry(int id, [FromBody] DescriptorEntry descriptorEntry)
        {
            if (id != descriptorEntry.DescriptorId)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DescriptorEntryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(Ok());
        }
Exemple #2
0
        public async Task <ActionResult <DescriptorEntry> > PostDescriptorEntry(DescriptorEntry descriptorEntry)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }

            _context.DescriptorEntries.Add(descriptorEntry);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (DescriptorEntryExists(descriptorEntry.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetDescriptorMatter", new { id = descriptorEntry.Id }, descriptorEntry));
        }
Exemple #3
0
 /// <summary>
 /// Creates a success response.
 /// </summary>
 /// <param name="category">Saved category.</param>
 /// <returns>Response.</returns>
 public SaveDescriptorEntryResponse(DescriptorEntry descriptorentry) : this(true, string.Empty, descriptorentry)
 {
 }
Exemple #4
0
 private SaveDescriptorEntryResponse(bool success, string message, DescriptorEntry descriptorentry) : base(success, message)
 {
     DescriptorEntry = descriptorentry;
 }