public static void assignTask(decimal id, decimal userId)
        {
            using (var conn = new db_entities()) {
                try {
                    var task = conn.tasks.Where(x => x.id == id).FirstOrDefault();

                    if (task != null)
                    {
                        task.task_status = "0";
                        task.assing_id   = userId;
                    }
                    conn.SaveChanges();

                    conn.SP_LOG_TASK(id, userId, DateTime.Now, "0");

                    var alert = conn.alerts.Where(x => x.task_id == id && x.state == 0).FirstOrDefault();

                    if (alert != null)
                    {
                        conn.SP_ALERT_UPDATE(alert.id, alert.message, id, DateTime.Now, 1);
                    }
                } catch (Exception e) {
                    throw e;
                }
            }
        }
        public static void acceptTask(decimal id, decimal userId)
        {
            using (var conn = new db_entities()) {
                try {
                    var task = conn.tasks.Where(x => x.id == id).FirstOrDefault();

                    if (task != null)
                    {
                        task.task_status = "4";
                    }
                    conn.SaveChanges();

                    conn.SP_LOG_TASK(id, userId, DateTime.Now, "4");
                } catch (Exception e) {
                    throw e;
                }
            }
        }
        public static void refuseTask(decimal id, String message, decimal userId)
        {
            using (var conn = new db_entities()) {
                try {
                    var task = conn.tasks.Where(x => x.id == id).FirstOrDefault();

                    if (task != null)
                    {
                        task.task_status = "3";
                    }

                    conn.SaveChanges();

                    conn.SP_ALERT_INSERT(message, id, DateTime.Now, 0);

                    conn.SP_LOG_TASK(id, userId, DateTime.Now, "3");
                } catch (Exception e) {
                    throw e;
                }
            }
        }
        public static void editTask(decimal id, String state, decimal userId)
        {
            using (var conn = new db_entities()) {
                try {
                    var task = conn.tasks.Where(x => x.id == id).FirstOrDefault();

                    if (task != null)
                    {
                        task.task_status = state;
                        task.assing_id   = userId;
                        if (state == "4")
                        {
                            task.date_start = DateTime.Now;
                        }
                    }

                    conn.SaveChanges();

                    conn.SP_LOG_TASK(id, userId, DateTime.Now, state);
                } catch (Exception e) {
                    throw e;
                }
            }
        }