Exemple #1
0
        public async Task <IActionResult> Put(string id, [FromBody] TblTaskCard item)
        {
            if (id != item.Id)
            {
                return(BadRequest());
            }
            item.UpdateTime            = DateTime.Now;
            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
        public async Task <IActionResult> PutPermissions(int id, Permissions permissions)
        {
            if (id != permissions.PermissionsId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutUser(int id, User user)
        {
            if (id != user.UserId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #4
0
        public async Task <ActionResult <Card> > PutCard(Guid id, Card card)
        {
            if (id != card.Id || card.Titulo == "" || card.Conteudo == "")
            {
                return(BadRequest());
            }

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

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

            Console.WriteLine($"{DateTime.Now} - Card {id} - {card.Titulo} - Alterar");

            return(card);
        }
Exemple #5
0
        public ActionResult Edit([Bind(Include = "Id,Name,Description,ProjectId,ColumnId,Position,CreatedDate,UpdatedDate")] Issue issue)
        {
            if (ModelState.IsValid)
            {
                var oldIssue = db.Issues.Where(p => p.Id == issue.Id).AsNoTracking().FirstOrDefault();
                if (issue.ProjectId != oldIssue.ProjectId)
                {
                    issue.ColumnId = null;
                }

                if (issue.ColumnId != oldIssue.ColumnId)
                {
                    if (issue.ColumnId == null) // ten warunek nigdy się nie spełni
                    {
                        issue.Position = 0;
                    }
                    else
                    {
                        var issuesQuantity = db.Issues.Where(c => c.ColumnId == issue.ColumnId).Count();
                        issue.Position = issuesQuantity + 1;
                    }
                }

                issue.UpdatedDate     = DateTime.Now;
                db.Entry(issue).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.ColumnId  = new SelectList(db.Columns, "Id", "Name", issue.ColumnId);
            ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", issue.ProjectId);
            return(View(issue));
        }
Exemple #6
0
        public async Task <IActionResult> PutCard(int id, Card card)
        {
            if (id != card.CardId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutTable(int id, Table table)
        {
            if (id != table.TableId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #8
0
        public async Task <IActionResult> PutGroup(int id, Group @group)
        {
            if (id != @group.GroupId)
            {
                return(BadRequest());
            }

            _context.Entry(@group).State = EntityState.Modified;

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

            return(NoContent());
        }
        public async Task <IActionResult> PutBoard_Members(int id, Board_Members board_Members)
        {
            if (id != board_Members.Board_MembersId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
 public ActionResult Edit([Bind(Include = "Id")] Board board)
 {
     if (ModelState.IsValid)
     {
         db.Entry(board).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Id = new SelectList(db.Projects, "Id", "Name", board.Id);
     return(View(board));
 }
Exemple #11
0
        public ActionResult Edit([Bind(Include = "Id,Name,BoardId")] Column column)
        {
            if (ModelState.IsValid)
            {
                db.Entry(column).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Show", "BoardViewModel", new { id = column.BoardId }));
            }

            return(View(column));
        }
        public ActionResult Edit([Bind(Include = "Id,Name,Description")] Project project)
        {
            if (ModelState.IsValid)
            {
                db.Entry(project).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(project));
        }
        public ActionResult Edit([Bind(Include = "ID,Title")] Section section)
        {
            if (ModelState.IsValid)
            {
                Section origSection = db.Sections.Find(section.ID);
                if (origSection == null)
                {
                    return(HttpNotFound());
                }
                if (origSection.Board.OwnerID != User.Identity.GetUserId())
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
                }
                origSection.Title           = section.Title.Trim();
                db.Entry(origSection).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "Boards", new { id = origSection.BoardID, sectionEditOpen = true }));
            }

            return(RedirectToAction("Index", "Boards", new { id = section.BoardID, errMessage = "Could not edit section, model not vaild", sectionEditOpen = true }));
        }
        public ActionResult Edit([Bind(Include = "Id,Name,Description,ProjectId,ColumnId,Position,CreatedDate,UpdatedDate")] IssueViewModel issueViewModel)
        {
            if (ModelState.IsValid)
            {
                Issue issue = new Issue();

                var oldIssue = db.Issues.Where(p => p.Id == issueViewModel.Id).AsNoTracking().FirstOrDefault();
                if (issueViewModel.ProjectId != oldIssue.ProjectId)
                {
                    issue.ColumnId = null;
                    // trzeba przenumerować pozycje
                }
                else
                {
                    issue.ColumnId = issueViewModel.ColumnId;
                }

                if (issueViewModel.ColumnId != oldIssue.ColumnId)
                {
                    if (issueViewModel.ColumnId == null)
                    {
                        issueViewModel.Position = 0;
                    }
                    else
                    {
                        var issuesQuantity = db.Issues.Where(c => c.ColumnId == issueViewModel.ColumnId).Count();
                        issueViewModel.Position = issuesQuantity + 1;
                    }
                    // trzeba przenumerować pozycje
                }

                issue.Id              = issueViewModel.Id;
                issue.Name            = issueViewModel.Name;
                issue.Description     = issueViewModel.Description;
                issue.ProjectId       = issueViewModel.ProjectId;
                issue.Position        = issueViewModel.Position;
                issue.CreatedDate     = issueViewModel.CreatedDate;
                issue.UpdatedDate     = DateTime.Now;
                db.Entry(issue).State = EntityState.Modified;
                db.SaveChanges();

                BusinessLogic.BoardBL.ResetIssuesPosition(oldIssue.ColumnId.GetValueOrDefault());

                if (issue.ProjectId == null)
                {
                    return(RedirectToAction("Index", "Issue"));
                }

                return(RedirectToAction("Show", "BoardViewModel", new { id = issue.ProjectId }));
            }

            return(View(issueViewModel));
        }
Exemple #15
0
 public ActionResult Edit(Manager manager, int ProjectId)
 {
     if (ProjectId != 0)
     {
         _db.ProjectManagers.Add(new ProjectManager()
         {
             ProjectId = ProjectId, ManagerId = manager.ManagerId
         });
     }
     _db.Entry(manager).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public ActionResult Edit([Bind(Include = "ID,Title")] Board board)
        {
            if (ModelState.IsValid)
            {
                Board origBoard = db.Boards.Find(board.ID);

                if (origBoard == null)
                {
                    return(HttpNotFound());
                }
                if (origBoard.OwnerID != User.Identity.GetUserId())
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
                }

                origBoard.Title           = board.Title;
                db.Entry(origBoard).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", new { boardEditOpen = true, id = board.ID }));
            }
            return(View(board));
        }
        public async Task <Item> EditItem(Item item)
        {
            _context.Entry(item).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();

                return(item);
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
Exemple #18
0
        public static void ResetIssuesPosition(int columnId)
        {
            KanbanContext db       = new KanbanContext();
            var           issues   = db.Issues.Where(c => c.ColumnId == columnId).OrderBy(p => p.Position).ToList();
            int           position = 1;

            foreach (Issue iss in issues)
            {
                iss.Position        = position;
                db.Entry(iss).State = EntityState.Modified;
                position++;
            }
            db.SaveChanges();
        }
Exemple #19
0
        public ActionResult Edit([Bind(Include = "ID,SectionID,Title,Content,CardColor")] Card card)
        {
            Card origCard = db.Cards.Find(card.ID);

            if (origCard == null)
            {
                return(HttpNotFound());
            }
            if (ModelState.IsValid)
            {
                if (origCard.Section.Board.OwnerID != User.Identity.GetUserId())
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
                }
                origCard.Title           = card.Title.Trim();
                origCard.Content         = card.Content;
                origCard.CardColor       = card.CardColor;
                db.Entry(origCard).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "Boards", new { id = origCard.Section.BoardID }));
            }

            return(RedirectToAction("Index", "Boards", new { id = origCard.Section.BoardID, errMessage = "Could not create card, model not vaild" }));
        }
Exemple #20
0
        public bool EditCard(EditCardDto editCardDto)
        {
            var card = GetCard(editCardDto.Id);

            if (card == null)
            {
                return(false);
            }

            card.Name = editCardDto.Name;
            _context.Entry(card).State = EntityState.Modified;

            var result = _context.SaveChanges();

            return(result > 0);
        }
        public ActionResult SendToBacklog(int?issueId)
        {
            if (issueId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Issue issue = db.Issues.Find(issueId);

            if (issue == null)
            {
                return(HttpNotFound());
            }
            issue.ColumnId        = null;
            issue.Position        = 0;
            issue.UpdatedDate     = DateTime.Now;
            db.Entry(issue).State = EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Show", new { id = issue.ProjectId }));
        }
 public ActionResult Edit(ToDoList todolist)
 {
     _db.Entry(todolist).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit(Project project)
 {
     _db.Entry(project).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }