// ---------------------------------------------------- Notifications Users ----------------------------------------------// public static List <TaskNotificationUserDTO> getTaskNotificationUsers(string id_notification) { List <TaskNotificationUserDTO> taskNotificationsUsers = new List <TaskNotificationUserDTO>(); using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString)) { SqlCommand command = new SqlCommand("usp_get_taskNotificationUser", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@id_notification", SqlDbType.Int); command.Parameters["@id_notification"].Value = id_notification; command.Connection.Open(); SqlDataReader rdr = command.ExecuteReader(); while (rdr.Read()) { TaskNotificationUserDTO taskNotificationUser = new TaskNotificationUserDTO(); taskNotificationUser.notification_id = rdr["notification_id"].ToString(); taskNotificationUser.user_id = rdr["user_id"].ToString(); taskNotificationUser.name = rdr["name"].ToString(); taskNotificationUser.sLastName = rdr["sLastName"].ToString(); taskNotificationUser.fLastName = rdr["fLastName"].ToString(); taskNotificationUser.userName = rdr["userName"].ToString(); taskNotificationUser.email = rdr["email"].ToString(); taskNotificationUser.telegram_id = rdr["telegram_id"].ToString(); byte[] photo = (byte[])rdr["photoData"]; taskNotificationUser.photoData = Convert.ToBase64String(photo); taskNotificationsUsers.Add(taskNotificationUser); } }; return(taskNotificationsUsers); }
public static bool insertTaskNotificationUser(TaskNotificationUserDTO pTaskNotificationType) { using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString)) { SqlCommand command = new SqlCommand("usp_insert_taskNotificationUser", connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add("@id_notification", SqlDbType.Int); command.Parameters["@id_notification"].Value = pTaskNotificationType.notification_id; command.Parameters.Add("@user_id", SqlDbType.Int); command.Parameters["@user_id"].Value = pTaskNotificationType.user_id; command.Parameters.Add("@userLog", SqlDbType.Int); command.Parameters["@userLog"].Value = pTaskNotificationType.userLog; command.Connection.Open(); string result = command.ExecuteNonQuery().ToString(); if (result != "0") { return(true); } }; return(false); }
public ActionResult _AddTaskNotificationUser(string id_notification, List <string> selected_userParticipants_id) { if (ModelState.IsValid) { TaskProvider taskProvider = new TaskProvider(); List <TaskNotificationUserDTO> taskNotificationUsers = new List <TaskNotificationUserDTO>(); foreach (var user_id in selected_userParticipants_id) { TaskNotificationUserDTO taskNotificationUser = new TaskNotificationUserDTO(); taskNotificationUser.user_id = user_id; taskNotificationUser.userLog = Request.Cookies["user_id"].Value; taskNotificationUser.notification_id = id_notification; taskNotificationUsers.Add(taskNotificationUser); } List <TaskNotificationUserDTO> adddedUsers = taskProvider.postTaskNotificationUser(taskNotificationUsers).Result; int addedCount = adddedUsers.Count; int errorCount = taskNotificationUsers.Count - addedCount; TaskNotificationDTO taskNotification = new TaskNotificationDTO(); taskNotification.id_notification = id_notification; var result = new { id_notification = id_notification, usersAdded = addedCount, usersError = errorCount, viewHtml = PartialView("/Views/Tasks/_Tasks/_TaskDetails/_TaskNotificationsUsers.cshtml", new Model.TaskNotificationsUserModel(taskNotification)).RenderToString() }; return(Json(result)); } return(new HttpStatusCodeResult(404, "Error, no se puede agregar la notificación")); }