public IHttpActionResult GetToDoTasksByList(int?listId, TaskType type) { if (listId == null) { return(BadRequest()); } DateTime basicDate = new DateTime(1970, 1, 1); List <Task> tasks = new List <Task>(); List <ByListIdTaskDTO> dtoTasks = new List <ByListIdTaskDTO>(); if (type == TaskType.todo) { tasks = _service.AllToDoByList(Convert.ToInt32(listId)).ToList(); } if (type == TaskType.done) { tasks = _service.AllDoneByList(Convert.ToInt32(listId)).ToList(); } foreach (var task in tasks) { dtoTasks.Add(new ByListIdTaskDTO { Id = task.Id, Name = task.Name, Created = System.Convert.ToInt64((TimeZoneInfo.ConvertTimeToUtc(task.Created) - basicDate).TotalMilliseconds), End = System.Convert.ToInt64((TimeZoneInfo.ConvertTimeToUtc(task.End.Value) - basicDate).TotalMilliseconds) }); } return(Ok(dtoTasks)); }