예제 #1
0
        public async Task <IActionResult> PutCampCreateModel(int id, CampCreateModel campCreateModel)
        {
            if (id != campCreateModel.CampId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> PutCamp([FromRoute] int id, [FromBody] Camp camp)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != camp.CampId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <bool> SaveChangesAsync()
        {
            _logger.LogInformation($"Attempitng to save the changes in the context");

            // Only return success if at least one row was changed
            return((await _context.SaveChangesAsync()) > 0);
        }
 public async Task Seed()
 {
     if (!_ctx.Camps.Any())
     {
         // Add Data
         _ctx.AddRange(_sample);
         await _ctx.SaveChangesAsync();
     }
 }
예제 #5
0
 public async Task <bool> SaveAllAsync()
 {
     return((await _context.SaveChangesAsync()) > 0);
 }