Exemple #1
0
        /// <summary>
        /// Adds ToDoList record
        /// </summary>
        /// <param name="createToDoListDto"></param>
        /// <returns> added ToDoList record. </returns>
        public async Task <ToDoListDto> AddToDoList(CreateToDoListDto createToDoListDto)
        {
            if (createToDoListDto != null)
            {
                createToDoListDto.CreatedBy = _userId;
            }
            ToDoListDto addedItem = await _toDoListDbOps.CreateToDoList(createToDoListDto);

            return(addedItem);
        }
Exemple #2
0
        /// <summary>
        /// Adds ToDoList record to ToDoList table.
        /// </summary>
        /// <param name="createToDoListDto"></param>
        /// <returns> added ToDoList record. </returns>
        public async Task <ToDoListDto> CreateToDoList(CreateToDoListDto createToDoListDto)
        {
            ToDoListDbModel toDoListDbDto = _mapper.Map <ToDoListDbModel>(createToDoListDto);

            toDoListDbDto.CreationDate = DateTime.UtcNow;
            _toDoDbContext.ToDoLists.Add(toDoListDbDto);
            await _toDoDbContext.SaveChangesAsync();

            return(_mapper.Map <ToDoListDto>(toDoListDbDto));
        }
        /// <summary>
        /// Adds the specified to do list dto.
        /// </summary>
        /// <param name="toDoListDto">To do list dto.</param>
        /// <returns></returns>
        public async Task <ToDoListDto> Add(CreateToDoListDto toDoListDto)
        {
            ToDoList toDoList = _mapper.Map <ToDoList>(toDoListDto);

            toDoList.CreatedOn = DateTime.UtcNow;
            toDoList.CreatedBy = toDoListDto.UserId;
            toDoList           = _toDoListRepository.Add(toDoList);
            await _toDoListRepository.Save();

            return(_mapper.Map <ToDoListDto>(toDoList));
        }
        public async Task <IActionResult> Add(CreateToDoListDto createToDoList, ApiVersion version)
        {
            int userId = int.Parse(HttpContext.Items["UserId"].ToString());

            if (createToDoList == null || string.IsNullOrWhiteSpace(createToDoList.Description))
            {
                return(BadRequest(new ResponseModel <string>
                {
                    IsSuccess = false,
                    Result = "Not Updated.",
                    Message = "Invalid request, mandatory fields not provided in request."
                }));
            }
            createToDoList.CreatedBy = userId;
            createToDoList.UserId    = userId;
            ToDoListDto createdToDoList = await _listService.Add(createToDoList);

            return(CreatedAtAction(nameof(GetById), new { id = createdToDoList.ToDoListId, version = $"{version}" }, createdToDoList));
        }
Exemple #5
0
        public async Task <IActionResult> CreateToDoList(CreateToDoListModel createToDoList, ApiVersion version)
        {
            long userId = long.Parse(HttpContext.Items["UserId"].ToString());

            if (createToDoList == null || string.IsNullOrWhiteSpace(createToDoList.Description))
            {
                return(BadRequest(new ApiResponse <string>
                {
                    IsSuccess = false,
                    Result = "Not Updated.",
                    Message = "Please enter correct values. Description should not be empty."
                }));
            }
            createToDoList.CreatedBy = userId;

            CreateToDoListDto createToDoListDto = _mapper.Map <CreateToDoListDto>(createToDoList);
            ToDoListDto       createdToDoList   = await _toDoListContract.CreateToDoList(createToDoListDto);

            return(CreatedAtAction(nameof(GetToDoListById), new { createdToDoList.ToDoListId, version = $"{version}" }, createdToDoList));
        }
Exemple #6
0
 /// <summary>
 /// Create ToDoList record.
 /// </summary>
 /// <param name="createToDoItemDto">Description,CreationDate,CreatedBy</param>
 /// <returns> Created ToDoItem record. </returns>
 public async Task <ToDoListDto> CreateToDoList(CreateToDoListDto createToDoListDto)
 {
     return(await _toDoListDbOps.CreateToDoList(createToDoListDto));
 }
 /// <summary>
 /// Adds the specified to do list dto.
 /// </summary>
 /// <param name="toDoListDto">To do list dto.</param>
 /// <returns></returns>
 public async Task <ToDoListDto> Add(CreateToDoListDto toDoListDto)
 {
     return(await _toDoListRepository.Add(toDoListDto));
 }