public List <BoardsModel> GetBoardsOfCommunity(int communityId) { List <BoardsModel> boards = new List <BoardsModel>(); using (var conn = new SqlConnection(connectionString)) using (var command = new SqlCommand("pr_GetBoardsOfCommunity", conn) { CommandType = CommandType.StoredProcedure }) { command.Parameters.Add("@CommunityId", SqlDbType.Int).Value = communityId; conn.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { var item = new BoardsModel(); item.UserName = reader["UserName"].ToString(); item.CommunityId = (Int32)reader["CommunityId"]; item.Genre = reader["Genre"].ToString(); item.Title = reader["Title"].ToString(); item.Content = reader["Content"].ToString(); boards.Add(item); } reader.Close(); } return(boards); }
public ActionResult Create(BoardsModel boardsModel) { var bm = BoardDataMapper.GetBoardDataMapper(); if (bm.GetByName(boardsModel.Name) == null) { bm.Add(boardsModel); var acc = AccountDataMapper.GetAccountDataMapper().GetById(User.Identity.Name); acc.AddBoard(boardsModel); return(RedirectToAction("Index")); } ModelState.AddModelError("Name", "Já existe um Quadro com esse nome"); return(View(boardsModel)); }
public ActionResult Edit(BoardsModel boardsModel) { var board = BoardDataMapper.GetBoardDataMapper().GetById(boardsModel.Id); if (board == null) { return(RedirectToAction("Http404", "Errors")); } if (!AccountDataMapper.GetAccountDataMapper().GetById(User.Identity.Name).CanWriteBoard(board.Id)) { return(RedirectToAction("Index")); } board.Name = boardsModel.Name; board.Description = boardsModel.Description; return(RedirectToAction("Index")); }
public IEnumerable <ListsModel> GetAllByBoard(BoardsModel board) { return(_lists.FindAll(list => list.Board.Id == board.Id)); }