Example #1
0
        public async Task <IActionResult> PostSmartWatchSessionData([FromBody] SmartWatchSessionData smartWatchSessionData)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.SmartWatchSessionData.Add(smartWatchSessionData);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (SmartWatchSessionDataExists(smartWatchSessionData.Interval))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetSmartWatchSessionData", new { id = smartWatchSessionData.Interval }, smartWatchSessionData));
        }
Example #2
0
        public async Task <IActionResult> PutSmartWatchSessionData([FromRoute] int id, [FromBody] SmartWatchSessionData smartWatchSessionData)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != smartWatchSessionData.Interval)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }