예제 #1
0
        public static List <TaskNotificationDTO> getTaskNotifications(string id_task)
        {
            List <TaskNotificationDTO> taskNotifications = new List <TaskNotificationDTO>();

            using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("usp_get_taskNotifications", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@id_task", SqlDbType.Int);
                command.Parameters["@id_task"].Value = id_task;
                command.Connection.Open();
                SqlDataReader rdr = command.ExecuteReader();
                while (rdr.Read())
                {
                    TaskNotificationDTO taskNotification = new TaskNotificationDTO();
                    taskNotification.id_notification = rdr["id_notification"].ToString();
                    taskNotification.message         = rdr["message"].ToString();
                    taskNotification.task_id         = rdr["task_id"].ToString();
                    taskNotification.isStarting      = rdr["isStarting"].ToString();
                    taskNotification.isEmail         = rdr["isEmail"].ToString();
                    taskNotification.isTelegram      = rdr["isTelegram"].ToString();
                    taskNotification.isIntern        = rdr["isIntern"].ToString();
                    taskNotifications.Add(taskNotification);
                }
            };
            return(taskNotifications);
        }
예제 #2
0
        public static bool updateTaskNotification(TaskNotificationDTO pTaskNotification)
        {
            using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("usp_update_taskNotification", connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.Parameters.Add("@id_notification", SqlDbType.Int);
                command.Parameters["@id_notification"].Value = pTaskNotification.id_notification;

                command.Parameters.Add("@message", SqlDbType.NVarChar);
                command.Parameters["@message"].Value = pTaskNotification.message;

                command.Parameters.Add("@isStarting", SqlDbType.Bit);
                command.Parameters["@isStarting"].Value = pTaskNotification.isStarting;

                command.Parameters.Add("@userLog", SqlDbType.Int);
                command.Parameters["@userLog"].Value = pTaskNotification.userLog;

                command.Connection.Open();
                string result = command.ExecuteNonQuery().ToString();
                if (result != "0")
                {
                    return(true);
                }
            };
            return(false);
        }
 public ActionResult _EditTaskNotification(Model.EditTaskNoficationModel pModel)
 {
     if (ModelState.IsValid)
     {
         TaskProvider        taskProvider     = new TaskProvider();
         TaskNotificationDTO taskNotification = new TaskNotificationDTO();
         taskNotification.id_notification = pModel.id_notification;
         taskNotification.message         = pModel.message;
         taskNotification.userLog         = Request.Cookies["user_id"].Value;
         taskNotification.isStarting      = "False";
         taskNotification.isTelegram      = pModel.isTelegram == "on" ? "True" : "False";
         taskNotification.isIntern        = pModel.isIntern == "on" ? "True" : "False";
         taskNotification.isEmail         = pModel.isEmail == "on" ? "True" : "False";
         taskNotification.task_id         = pModel.id_task;
         if (taskProvider.putTaskNotification(taskNotification).Result)
         {
             if (taskNotification.isTelegram == "True")
             {
             }
             if (taskNotification.isIntern == "True")
             {
             }
             if (taskNotification.isEmail == "True")
             {
             }
             return(_TaskNotificationList(taskNotification.task_id));
         }
     }
     return(new HttpStatusCodeResult(404, "Error, no se puede agregar la notificación"));
 }
        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"));
        }
        public ActionResult _TaskNotificationUsers(string id_notification)
        {
            TaskNotificationDTO taskNotification = new TaskNotificationDTO();

            taskNotification.id_notification = id_notification;
            return(PartialView("/Views/Tasks/_Tasks/_TaskDetails/_TaskNotificationUsers.cshtml", new Model.TaskNotificationsUserModel(taskNotification)));
        }
 public IHttpActionResult putTaskNotification(TaskNotificationDTO pTaskNotification)
 {
     if (!TaskNotificationsData.updateTaskNotification(pTaskNotification))
     {
         return(BadRequest());
     }
     return(Ok());
 }
예제 #7
0
 public async Task <bool> putTaskNotification(TaskNotificationDTO taskNotificationDTO)
 {
     using (var client = new HttpClient())
     {
         client.BaseAddress = new Uri(_BaseAddress);
         var         userJson    = new JavaScriptSerializer().Serialize(taskNotificationDTO);
         HttpContent contentPost = new StringContent(userJson, Encoding.UTF8, "application/json");
         client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", getToken());
         HttpResponseMessage response = client.PutAsync("api/tasks/notifications", contentPost).Result;
         return(response.IsSuccessStatusCode);
     }
 }
        public EditTaskNoficationModel(TaskNotificationDTO taskNoficationDTO, TaskDTO pTaskDTO)
        {
            taskDTO = pTaskDTO;
            this.taskNoficationDTO = taskNoficationDTO;
            this.message           = taskNoficationDTO.message;
            this.id_notification   = taskNoficationDTO.id_notification;
            this.isTelegram        = taskNoficationDTO.isTelegram;
            this.isIntern          = taskNoficationDTO.isIntern;
            this.isEmail           = taskNoficationDTO.isEmail;
            this.id_task           = taskNoficationDTO.task_id;
            userList = taskProvider.getTaskParticipants(taskDTO.id_task).Result;
            List <SelectListItem> usersSelectList = new List <SelectListItem>();

            foreach (ParticipantDTO iUser in userList)
            {
                var name = iUser.name + " " + iUser.fLastName + " " + iUser.sLastName;
                usersSelectList.Add(new SelectListItem {
                    Text = name, Value = iUser.user_id
                });
            }
            _ParticipantsSelect = new SelectList(usersSelectList, "Value", "Text");
        }
 public TaskNotificationsUserModel(TaskNotificationDTO taskNoficationDTO)
 {
     this.taskNoficationDTO = taskNoficationDTO;
     this.users             = taskProvider.getTaskNotificationUsers(taskNoficationDTO.id_notification).Result;
 }