public ActionResult Archive(int bid, int cid, Agreement agreement) { if (agreement.Answer) { var card = RepoCard.GetById(bid); if (card == null || card.BoardId != bid) { Response.StatusCode = HttpStatusCodes.BadRequest; return View("Error"); } if (!card.IsArchived) { var list = RepoBoardList.GetById(card.BoardListId); RepoCard.UpdatePositionsDown(card.Position, card.BoardListId); list.NumberOfCards -= 1; card.IsArchived = true; return new SeeOtherResult { Uri = Url.Action("Show", "Lists", new { bid, lid = card.BoardListId }) }; } } return new SeeOtherResult { Uri = Url.Action("Show", "Cards", new { bid, cid }) }; }
public ActionResult RemoveUser(string nickName, Agreement agreement) { if (!User.Identity.Name.Equals(nickName) && !RepoUser.GetById(User.Identity.Name).CurrentRole.Equals(RoleStatus.Admin)) { Response.StatusCode = HttpStatusCodes.Forbiden; return View("Error"); } if (!ModelState.IsValid) { Response.StatusCode = HttpStatusCodes.BadRequest; return View("Error"); } if (agreement.Answer) { var user = RepoUser.GetById(nickName); if (user != null) { if(user.Id.Equals(User.Identity.Name)) { FormsAuthentication.SignOut(); } RepoUser.Remove(nickName); return User.Identity.Name.Equals(nickName) ? new SeeOtherResult { Uri = Url.Action("Login", "Users") } : new SeeOtherResult { Uri = Url.Action("Manage", "Users") }; } Response.StatusCode = HttpStatusCodes.BadRequest; return View("Error"); } return User.Identity.Name.Equals(nickName) ? new SeeOtherResult {Uri = Url.Action("Show", "Users")} : new SeeOtherResult { Uri = Url.Action("Manage", "Users") }; }
public ActionResult RemovePermit(int bid, string nickName, Agreement agreement) { if (agreement.Answer) { var board = RepoBoard.GetById(bid); if (board != null) { var user = RepoUser.GetById(nickName); if (user != null) { var permit = board.Permits.Find(p => p.User == user); if (permit != null) { board.Permits.Remove(permit); return new SeeOtherResult { Uri = Url.Action("BoardPermits", new { bid }) }; } } } Response.StatusCode = HttpStatusCodes.BadRequest; return View("Error"); } return new SeeOtherResult { Uri = Url.Action("BoardPermits", new { bid }) }; }
public ActionResult Remove(int bid, int lid, Agreement agreement) { if (agreement.Answer) { var list = RepoBoardList.GetById(lid); if (list == null || list.BoardId != bid) { Response.StatusCode = HttpStatusCodes.BadRequest; return View("Error"); } var pos = list.Position; if (!RepoBoardList.Remove(lid)) { Response.StatusCode = HttpStatusCodes.InternalServerError; return View("Error"); } var board = RepoBoard.GetById(list.BoardId); board.NumberOfLists -= 1; RepoBoardList.UpdatePositionsDown(pos, board.Id); return new SeeOtherResult { Uri = Url.Action("Show", "Boards", new { bid }) }; } return new SeeOtherResult { Uri = Url.Action("Show", "Lists", new { bid, lid }) }; }