Beispiel #1
0
        public async Task <IActionResult> PutTholiday(long id, Tholiday tholiday)
        {
            if (id != tholiday.TholidayId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #2
0
        public async Task <ActionResult <Tholiday> > PostTholiday(Tholiday tholiday)
        {
            _context.Tholiday.Add(tholiday);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TholidayExists(tholiday.TholidayId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetTholiday", new { id = tholiday.TholidayId }, tholiday));
        }