public async Task <ActionResult> AddUser(int CourseId, int[] Ids) { var model = new UpdateTrainerCourseModel { CourseId = CourseId, UserId = Ids.ToList() }; var response = await WepApiMethod.SendApiAsync <bool>(HttpVerbs.Post, $"eLearning/Courses/AddUser", model); if (response.isSuccess) { TempData["SuccessMessage"] = "User successfully assigned to role trainer/instructor."; await LogActivity(Modules.Learning, "Assign user to trainer", model); // Notification var notifyModel = new NotificationModel { Id = CourseId, Type = typeof(Course), NotificationType = NotificationType.Course_Assigned_To_Facilitator, NotificationCategory = NotificationCategory.Learning, StartNotificationDate = DateTime.Now, ParameterListToSend = new ParameterListToSend { Link = this.Url.AbsoluteAction("View", "Courses", new { id = CourseId }), }, ReceiverType = ReceiverType.UserIds, Receivers = Ids.ToList(), IsNeedRemainder = false, }; var emailResponse = await EmaiHelper.SendNotification(notifyModel); if (emailResponse == null || String.IsNullOrEmpty(emailResponse.Status) || !emailResponse.Status.Equals("Success", System.StringComparison.OrdinalIgnoreCase)) { await LogError(Modules.Learning, $"Error Sending Email For Facilitator When Assigned to A Course. Course Id : {CourseId}"); } } else { TempData["ErrorMessage"] = "Fail to assign role."; } return(RedirectToAction("Trainers", "Courses", new { area = "eLearning", id = CourseId })); }
public async Task <ActionResult> DeleteUser(int CourseId, int[] Ids) { var model = new UpdateTrainerCourseModel { CourseId = CourseId, UserId = Ids.ToList() }; var response = await WepApiMethod.SendApiAsync <bool>(HttpVerbs.Post, $"eLearning/Courses/DeleteUser", model); if (response.isSuccess) { TempData["SuccessMessage"] = "User successfully remove from role."; await LogActivity(Modules.Setting, "Remove User From Role", model); } else { TempData["ErrorMessage"] = "Fail to remove user."; } return(RedirectToAction("Trainers", "Courses", new { area = "eLearning", id = CourseId })); }