Esempio n. 1
0
        public async Task <IActionResult> PutDay([FromRoute] int id, [FromBody] Day day)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != day.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public ActionResult PutDay([Required] int capstoneId, [Required] int dayId, [FromBody, Required] Day day)
        {
            if (capstoneId != day.CapstoneId)
            {
                return(BadRequest());
            }

            _dayContext.Entry(day).State = EntityState.Modified;

            try
            {
                _dayContext.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!dayRepository.DayExists(dayId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }


            return(Ok());
        }