示例#1
0
        public async Task <DBtask> PostTask(DBtask task)
        {
            _context.Tasks.Add(task);
            await _context.SaveChangesAsync();

            return(task);
        }
示例#2
0
        public async Task <ActionResult <DBtask> > PostDBtask(DBtask dBtask)
        {
            if (_taskService.taskExistsByName(dBtask.TaskName))
            {
                return(BadRequest());
            }
            var task = await _taskService.PostTask(dBtask);

            return(CreatedAtAction("GetDBtask", new { id = dBtask.Id }, task));
        }
示例#3
0
        public async Task <DBtask> UpdateTask(int id, DBtask dBtask)
        {
            dBtask.Id = id;
            _context.Entry(dBtask).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (DBtaskExists(id))
                {
                    throw;
                }
            }

            return(await GetTask(id));
        }
示例#4
0
        public async Task <IActionResult> PutDBtask(int id, DBtask dBtask)
        {
            var Result = await _taskService.UpdateTask(id, dBtask);

            return(NoContent());
        }