/// <summary> /// Updates to do list. /// </summary> /// <param name="todolist">The todolist.</param> /// <returns></returns> public ToDoListDTO UpdateToDoList(ToDoListDTO todolist) { ToDoListEntity entity = _mapper.Map <ToDoListDTO, ToDoListEntity>(todolist); _repo.Update(entity, todolist.Id); return(todolist); }
/// <summary> /// Adds to do list. /// </summary> /// <param name="todolist">The todolist.</param> /// <returns></returns> public ToDoListDTO AddToDoList(ToDoListDTO todolist) { ToDoListEntity entity = _mapper.Map <ToDoListDTO, ToDoListEntity>(todolist); entity.CreatedDate = DateTime.Now; _repo.Add(entity); return(todolist); }
public void AddToDoList_InValidData() { ToDoListEntity entity = null; ToDoListDTO dto = null; _mapper.Setup(p => p.Map <ToDoListDTO, ToDoListEntity>(dto)).Returns(entity); _repo.Setup(p => p.Add(entity)).Returns(0); var returnObj = _toDoListService.AddToDoList(dto); Assert.IsTrue(returnObj == null); }
public void Delete(ToDoListEntity toDoListEntity) { if (toDoListEntity.Id == 0) { throw new Exception("Select a todolist to delete"); } var todolist = _toDoListRepository.GetById(toDoListEntity.Id); var todolistid = todolist.CategoryId; _toDoListRepository.Delete(todolist); }
public void Save(ToDoListEntity toDoListEntity) { if (toDoListEntity.Id == 0) { _toDoListRepository.Insert(toDoListEntity); } else { _toDoListRepository.Update(toDoListEntity); } }
public JsonResult GetItems(int toDoListId) { if (!User.Identity.IsAuthenticated) { return(Json(new { redirect = "/account/login/" }, JsonRequestBehavior.AllowGet)); } var user = userService.GetByEmail(User.Identity.Name); ToDoListEntity currentToDoList = toDoListService.GetById(toDoListId); //TODO check that user has permission to get items. var res = itemService.GetByToDoListId(toDoListId).Select(toDoList => mapper.Map <ItemEntity, ItemModel>(toDoList)).ToArray(); return(Json(res, JsonRequestBehavior.AllowGet)); }
public void AddToDoList_ValidData() { var dto = new ToDoListDTO { Id = 11, Description = "Desc_11", LabelId = 1, CreatedBy = 1, UpdatedBy = 1, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now }; var entity = new ToDoListEntity { Id = 11, Description = "Desc_11", LabelId = 1, CreatedBy = 1, UpdatedBy = 1, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now }; _mapper.Setup(p => p.Map <ToDoListDTO, ToDoListEntity>(dto)).Returns(entity); _repo.Setup(p => p.Add(entity)).Returns(1); var returnObj = _toDoListService.AddToDoList(dto); Assert.AreEqual(11, returnObj.Id); }