public IActionResult Complete([Bind] SimpleTask task) { var status = new SimpleTaskStatus() { Id = Guid.NewGuid().ToString(), TaskId = task.Id, RegistrationDate = DateTime.Now, RegistrationUser = CurrentUser, Status = TaskStatusType.Done }; var request = Common.SecureRequest.RequestClient.Request($"{this.MyAPIUrl}/api/task/{task.Id}", Method.PUT, status); if (!request.Success && !string.IsNullOrEmpty(request.Message)) { ModelState.AddModelError(string.Empty, request.Message); return(View(task)); } return(RedirectToAction(nameof(Index))); }
public async Task <OperationResult> CreateNotificationFor(SimpleTaskStatus status) { var users = new List <SimpleUser>(); var task = GetTask(status.TaskId).Data; if (task?.State.Count > 1) { task.State.ForEach(item => { if (!users.Any(u => u.Id == item.RegistrationUser.Id)) { users.Add(item.RegistrationUser); } }); } else { users.Add(status.RegistrationUser); } foreach (var user in users) { var notification = new Notification() { Id = Guid.NewGuid().ToString(), User = user, Destination = user.Email, RegistrationDate = DateTime.Now, Subject = "Task Change Notification", TaskId = status.TaskId, TaskStatusId = status.Id, Message = "<%Notification Template%>" }; var res = await SaveNotificationAsync(notification); if (res.Success) { await QueueNotificationMessage(notification.Id); } } return(new OperationResult(true)); }
public async Task <OperationResult> UpdateTaskStatusAsync(SimpleTaskStatus record) { var validation = record.Validate(); if (!validation.IsValid) { return(new OperationResult(false, validation.ResultsToHtml())); } var endpoint = UriFactory.CreateDocumentCollectionUri(_db.DatabaseName, _db.TaskCollectionName); using (var client = _db.NewClient()) { var task = _db.QueryTask(client).Where(t => t.Id == record.TaskId).AsEnumerable().FirstOrDefault(); if (task != null) { if (task.State == null || !task.State.Any(state => state.Status == record.Status)) { task.State = task.State ?? new List <SimpleTaskStatus>(); task.State.Add(record); var response = await client.UpsertDocumentAsync(endpoint, task); await _notificationRepository.CreateNotificationFor(record); return(new OperationResult(true) { RecordId = task.Id }); } else { return(new OperationResult(false, "Task already contains the specified status type")); } } return(new OperationResult(false, "Task not found")); } }
void DrawSection(SimpleTaskStatus status) { string caption = ""; switch (status) { case SimpleTaskStatus.Created: caption = "created tasks"; break; case SimpleTaskStatus.Started: caption = "started tasks"; break; case SimpleTaskStatus.Done: caption = "completed tasks"; break; } EditorStyles.label.alignment = TextAnchor.LowerCenter; EditorGUILayout.BeginVertical(GUILayout.Width(columnWidth + 20)); EditorGUILayout.LabelField(caption, GUILayout.Width(columnWidth)); EditorGUILayout.LabelField("", GUI.skin.horizontalSlider, GUILayout.Width(columnWidth)); if (status == SimpleTaskStatus.Created) { if (GUILayout.Button("Create")) { SimpleTask t = new SimpleTask() { name = "new task", status = SimpleTaskStatus.Created, priority = 3 }; manager.tasksList.Add(t); TaskEditor.OpenTaskEditor(t); } EditorGUILayout.Space(); } scrolls[(int)status] = GUILayout.BeginScrollView(scrolls[(int)status], GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); List <SimpleTask> tasks = new List <SimpleTask>(manager.tasksList); tasks.Sort((p1, p2) => p1.priority.CompareTo(p2.priority)); foreach (SimpleTask task in tasks) { if (task.status != status) { continue; } if (currentFilter > -1 && currentFilter != (int)task.type) { continue; } if (searchString != "" && !task.name.ToLower().Contains(searchString.ToLower())) { continue; } DrawTask(task); } GUILayout.EndScrollView(); EditorGUILayout.EndVertical(); EditorGUILayout.LabelField("", GUI.skin.verticalSlider, GUILayout.Width(10)); }
public async Task <IActionResult> Put(string id, [FromBody] SimpleTaskStatus record) { var result = await _taskRepository.UpdateTaskStatusAsync(record); return(Ok(result)); }