예제 #1
0
        public async Task <IActionResult> PutLogbooks([FromRoute] int id, [FromBody] Logbooks Logbooks)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,AspNetUserId,Moment,Eventdescription")] Logbooks Logbooks)
        {
            if (id != Logbooks.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(Logbooks);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LogbooksExists(Logbooks.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AspNetUserId"] = new SelectList(_context.AspNetUsers, "Id", "Id", Logbooks.AspNetUserId);
            return(View(Logbooks));
        }
예제 #3
0
        public async Task <IActionResult> PostLogbooks([FromBody] Logbooks Logbooks)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Logbooks.Add(Logbooks);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLogbooks", new { id = Logbooks.Id }, Logbooks));
        }
예제 #4
0
        public async Task <IActionResult> CreateLogTask([Bind("Id,AspNetUserId,Moment,Eventdescription")] Logbooks Logbooks)
        {
            if (ModelState.IsValid)
            {
                _context.Add(Logbooks);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AspNetUserId"] = new SelectList(_context.AspNetUsers, "Id", "Id", Logbooks.AspNetUserId);
            return(View(Logbooks));
        }