예제 #1
0
        public async Task <ActionResult <ICollection <List> > > Post([FromBody] List model)
        {
            try
            {
                var userName = this.User.Identity.Name;
                var user     = await _userManager.FindByEmailAsync(userName);

                if (this.User.Identity.IsAuthenticated && userName != null)
                {
                    // call repo here, pass model
                    var result = _listRepository.CreateList(model, userName, user);
                    // save all fixes the model so that it contains the id from the database.
                    //return Created($"/api/lists/{model.Id}", model);
                    return(Created($"/api/lists", result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status401Unauthorized, "Unauthorized request"));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed to create new list: {ex}");
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure, list was not created"));
            }
        }
예제 #2
0
 public async Task CreateList(string boardId, List list)
 {
     if (list.ListCards == null)
     {
         list.ListCards = new List <Card>();
     }
     await listRepository.CreateList(boardId, list);
 }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Lists"></param>
        /// <returns></returns>
        public bool CreateList(ListDTO Lists)
        {
            var     result = false;
            TblList list   = _mapper.Map <TblList>(Lists);

            result = _listRepository.CreateList(list);
            return(result);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Lists"></param>
        /// <returns></returns>
        public ListDTO CreateList(ListDTO Lists)
        {
            TblList list = _mapper.Map <TblList>(Lists);

            list.CreatedDate = DateTime.UtcNow;
            list.ListId      = Guid.NewGuid().ToString();
            list             = _listRepository.CreateList(list);
            ListDTO listdto = _mapper.Map <ListDTO>(list);

            return(listdto);
        }
예제 #5
0
        public ActionResult Post([FromBody] ListDTO list)
        {
            try
            {
                var result = list_repo_.CreateList(list);

                return(this.Ok(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #6
0
        public ListDto CreateList(AddListDto listDto, string userId)
        {
            if (!_boardRepository.IsOwner(listDto.BoardId, userId))
            {
                return(null);
            }

            var list     = _mapper.Map <List>(listDto);
            var position = _listRepository.GetNumberOfListsInBoard(listDto.BoardId) + 1;

            list.Position = position;
            var addedList = _listRepository.CreateList(list);
            var result    = _mapper.Map <ListDto>(addedList);

            return(result);
        }
예제 #7
0
 public IActionResult CreateList(string title)
 {
     _listRepository.CreateList(temp_uid, title);
     return(Redirect("~/Dashboard/"));
 }
예제 #8
0
 public ToDoList CreateNewList(ToDoList toDoList)
 {
     return(_listRepo.CreateList(toDoList));
 }