public async Task <IActionResult> PutSeverity(Guid id, Severity severity)
        {
            if (id != severity.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <TaskItem> UpdateTask(UpdateTaskItemCommand command)
        {
            var existingItem = await _context.TaskItems.FindAsync(command.Id);

            if (existingItem == null)
            {
                throw new ArgumentOutOfRangeException(nameof(command.Id));
            }

            if (existingItem.Status == TaskItem.TaskStatus.Closed)
            {
                throw new InvalidOperationException("cannot change task in this status");
            }

            existingItem.ProjectID   = command.ProjectId;
            existingItem.Priority    = command.Priority;
            existingItem.Status      = command.Status;
            existingItem.Description = command.Description;
            existingItem.Name        = command.Name;
            existingItem.Modified    = DateTime.UtcNow;

            _context.TaskItems.Add(existingItem);
            _context.Entry(existingItem).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(existingItem);
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "Id,Status,Text,DateCreated")] Bug bug)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bug).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(bug));
 }
Exemplo n.º 4
0
 public (bool, string) ChangestateofWorkItem(int id, WorkItemStatus status)
 {
     try
     {
         var item = db.WorkItem.Find(id);
         if (item == null)
         {
             return(false, "Item not found");
         }
         else
         {
             item.Status          = status;
             db.Entry(item).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             return(true, "Item updated");
         }
     }
     catch (Exception ex)
     {
         return(false, ex.Message);
     }
 }
Exemplo n.º 5
0
        public async Task <ProjectItem> UpdateProject(UpdateProjectItemCommand command)
        {
            var existingItem = await _context.ProjectItems.FindAsync(command.Id);

            if (existingItem == null)
            {
                throw new ArgumentOutOfRangeException(nameof(command.Id));
            }

            existingItem.Name        = command.Name;
            existingItem.Description = command.Description;

            existingItem.Modified = DateTime.UtcNow;

            _context.ProjectItems.Add(existingItem);

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

            await _context.SaveChangesAsync();

            return(existingItem);
        }