public GetToDoRs GetToDoById(GetToDoRq request) { var response = new GetToDoRs(); var result = _dbRepository.FirstOrDefault <ToDo>(e => e.Id == request.Id); response.Id = result.Id; response.Name = result.Name; IQueryable <ToDoTask> toDoTaskList = null; if (request.CompletedTask) { toDoTaskList = _dbRepository.Where <ToDoTask>(e => e.ToDoId == request.Id && e.Completed == true); } if (request.ExpireDate) { toDoTaskList = _dbRepository.Where <ToDoTask>(e => e.ToDoId == request.Id && e.ExpireDateTime < DateTime.Now); } if (!request.ExpireDate && !request.CompletedTask) { toDoTaskList = _dbRepository.Where <ToDoTask>(e => e.ToDoId == request.Id && e.Completed == false); } response.ToDoTaskList = new List <ToDoTaskServiceModel>(); if (toDoTaskList == null) { return(response); } foreach (var item in toDoTaskList) { response.ToDoTaskList.Add(new ToDoTaskServiceModel { Id = item.Id, ExpireDateTime = item.ExpireDateTime, ToDoId = item.ToDoId, TaskName = item.TaskName, Completed = item.Completed, Description = item.Description }); } return(response); }
public LoginRs Login(LoginRq request) { var response = new LoginRs(); var user = _dbRepository.FirstOrDefault <User>(e => e.EmailAdress.Equals(request.Email) && e.Password.Equals(request.Password)); if (user == null) { response.IsSuccess = false; response.Message = "The email or password entered is incorrect."; return(response); } response.UserId = user.Id; return(response); }