コード例 #1
0
        public async Task <IActionResult> Create(InputModels.CreateBoardInput input)
        {
            if (ModelState.IsValid)
            {
                var serviceResponse = BoardRepository.AddBoard(input);
                return(await ForumViewResult.RedirectFromService(this, serviceResponse, FailureCallback));
            }

            return(await FailureCallback());

            async Task <IActionResult> FailureCallback()
            {
                var viewModel = new PageViewModels.CreatePage()
                {
                    Categories = BoardRepository.CategoryPickList()
                };

                viewModel.Name        = input.Name;
                viewModel.Description = input.Description;

                if (!string.IsNullOrEmpty(input.Category))
                {
                    viewModel.Categories.First(item => item.Value == input.Category).Selected = true;
                }

                return(await Task.Run(() => { return ForumViewResult.ViewResult(this, viewModel); }));
            }
        }
コード例 #2
0
        public Board AddBoard([FromBody] Board boardData)
        {
            var userId = HttpContext.User.Claims.Where(c => c.Type == ClaimTypes.Name)
                         .Select(c => c.Value).SingleOrDefault();

            boardData.UserId = userId;
            try
            {
                return(_boardRepo.AddBoard(boardData));
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
                return(null);
            }
        }
コード例 #3
0
        public HttpResponseMessage Create(JObject moveTaskParams)
        {
            dynamic json     = moveTaskParams;
            string  data     = Convert.ToString(json.data);
            var     response = Request.CreateResponse();

            if (json.boardId == null)
            {
                response.StatusCode = HttpStatusCode.BadRequest;
            }
            ProjectBoards ProjectBoard = repo.GetBoard(json);

            if (ProjectBoard == null)
            {
                repo.AddBoard(json);
            }

            response.StatusCode = HttpStatusCode.OK;
            return(response);
        }