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;
                }
            }
        }
        /**
         * Método para actualizar el registro
         */
        public static void update(decimal id, String name, int state, List <modules> modules)
        {
            using (var conn = new db_entities()) {
                try {
                    var entity = conn.roles.Where(x => x.id == id).FirstOrDefault();

                    if (entity == null)
                    {
                        throw new NotExistsException();
                    }
                    else
                    {
                        conn.SP_ROL_UPDATE(id, name, DateTime.Now, state);

                        // removemos los items
                        foreach (roles_modules rm in conn.roles_modules.Where(x => x.rol_id == entity.id).ToList())
                        {
                            conn.roles_modules.Remove(rm);
                        }
                        conn.SaveChanges();

                        // agregamos las actualizaciones
                        foreach (modules item in modules)
                        {
                            conn.SP_ROL_MODULE_INSERT(entity.id, item.id);
                        }
                    }
                } catch (Exception e) {
                    throw e;
                }
            }
        }
        public static decimal createTask(tasks tasks)
        {
            using (var conn = new db_entities()) {
                try {
                    conn.SP_TASK_INSERT(tasks.name, tasks.description,
                                        tasks.process_id, tasks.father_taks_id,
                                        tasks.task_status, tasks.date_start,
                                        tasks.date_end, DateTime.Now,
                                        tasks.creator_user_id, tasks.assing_id);
                    var result = conn.tasks.Where(x => x.name == tasks.name &&
                                                  x.description == tasks.description &&
                                                  x.creator_user_id == tasks.creator_user_id).FirstOrDefault();

                    if (result != null)
                    {
                        log_task logTask = new log_task();
                        logTask.task_id          = result.id;
                        logTask.task_status_code = tasks.task_status;
                        conn.log_task.Add(logTask);
                        //conn.SaveChanges();

                        return(result.id);
                    }
                    else
                    {
                        return(-1);
                    }
                } catch (Exception e) {
                    throw e;
                }
            }
        }
 /**
  * Método para actualizar el registro
  */
 public static void update(users user)
 {
     using (var conn = new db_entities()) {
         try {
             var entity = conn.users.Where(x => x.id == user.id).FirstOrDefault();
             user.updated_at = new DateTime();
             if (entity == null)
             {
                 throw new NotExistsException();
             }
             else
             {
                 if (user.password == null || user.password == "")
                 {
                     conn.SP_USER_UPDATE_WITHOUT_PASSWORD(user.id, user.name, user.email, user.rol_id, user.unit_id,
                                                          DateTime.Now, user.state);
                 }
                 else
                 {
                     conn.SP_USER_UPDATE_WITH_PASSWORD(user.id, user.name, user.email, user.password, user.rol_id, user.unit_id,
                                                       DateTime.Now, user.state);
                 }
             }
         } catch (Exception e) {
             throw e;
         }
     }
 }
Example #5
0
 public static List <templates_tasks> fetchAllByTemplateId(decimal id)
 {
     using (var conn = new db_entities()) {
         try {
             return(conn.templates_tasks.Where(x => x.template_id == id).ToList());
         } catch (Exception e) {
             throw e;
         }
     }
 }
 public static List <tasks> getTasksByProcessId(decimal id)
 {
     using (var conn = new db_entities()) {
         try {
             return(conn.tasks.Where(x => x.process_id == id).ToList());
         } catch (Exception e) {
             throw e;
         }
     }
 }
 public static List <tasks> getCreationTasksByUser(decimal id)
 {
     using (var conn = new db_entities()) {
         try {
             return(conn.tasks.Where(x => x.creator_user_id == id).ToList());
         } catch (Exception e) {
             throw e;
         }
     }
 }
 public static List <tasks> getAssignTasksByUser(decimal id)
 {
     using (var conn = new db_entities()) {
         try {
             return(conn.tasks.Where(x => x.assing_id == id && x.task_status == "0").ToList());
         } catch (Exception e) {
             throw e;
         }
     }
 }
 /**
  * Método para crear nuevo registro
  */
 public static void insert(String name, decimal?boss, decimal?enterprise_id)
 {
     using (var conn = new db_entities()) {
         try {
             conn.SP_UNIT_INSERT(name, DateTime.Now, 1, boss, enterprise_id);
         } catch (Exception e) {
             throw e;
         }
     }
 }
 public static void createDocument(files file)
 {
     using (var conn = new db_entities()) {
         try {
             conn.SP_FILE_INSERT(file.task_id, file.name, file.url, file.path, DateTime.Now);
         } catch (Exception e) {
             throw e;
         }
     }
 }
 /**
  * Método para crear nuevo registro
  */
 public static void insert(String message, decimal id)
 {
     using (var conn = new db_entities()) {
         try {
             conn.SP_ALERT_INSERT(message, id, DateTime.Now, 0);
         } catch (Exception e) {
             throw e;
         }
     }
 }
 public static alerts fetchByTaskId(long id)
 {
     using (var conn = new db_entities()) {
         try {
             return(conn.alerts.Where(x => x.task_id == id && x.state == 0).FirstOrDefault());
         } catch (Exception e) {
             throw e;
         }
     }
 }
Example #13
0
 /**
  * Método para devolver lista de los registros
  */
 public static config_traffic_lights fetch()
 {
     using (var conn = new db_entities()) {
         try {
             return(conn.config_traffic_lights.FirstOrDefault());
         } catch (Exception e) {
             throw e;
         }
     }
 }
Example #14
0
 /**
  * Método para actualizar el registro
  */
 public static void update(long id, int green, int yellow, int red)
 {
     using (var conn = new db_entities()) {
         try {
             conn.SP_CONFIG_TRAFFIC_LIGHTS_UPDATE(id, green, yellow, red, DateTime.Now);
         } catch (Exception e) {
             throw e;
         }
     }
 }
Example #15
0
 /**
  * Método para crear nuevo registro
  */
 public static void insert(String name)
 {
     using (var conn = new db_entities()) {
         try {
             conn.SP_ENTERPRISE_INSERT(name, DateTime.Now, 1);
         } catch (Exception e) {
             throw e;
         }
     }
 }
 public static List <files> fetchAllByTaskId(long id)
 {
     using (var conn = new db_entities()) {
         try {
             return(conn.files.Where(x => x.task_id == id).ToList());
         } catch (Exception e) {
             throw e;
         }
     }
 }
Example #17
0
 /**
  * Método para actualizar el registro
  */
 public static void update(decimal id, String name, int state)
 {
     using (var conn = new db_entities()) {
         try {
             conn.SP_ENTERPRISE_UPDATE(id, name, DateTime.Now, state);
         } catch (Exception e) {
             throw e;
         }
     }
 }
 public static tasks fetchById(decimal id)
 {
     using (var conn = new db_entities()) {
         try {
             return(conn.tasks.Where(x => x.id == id).FirstOrDefault());
         } catch (Exception e) {
             throw e;
         }
     }
 }
Example #19
0
 /**
  * Método para devolver lista de los registros
  */
 public static List <modules> fetchAll()
 {
     using (var conn = new db_entities()) {
         try {
             return(conn.modules.ToList());
         } catch (Exception e) {
             throw e;
         }
     }
 }
 public static process getById(decimal id)
 {
     using (var conn = new db_entities()) {
         try {
             return(conn.process.Where(r => r.id == id).FirstOrDefault());
         } catch (Exception e) {
             throw e;
         }
     }
 }
Example #21
0
 /**
  * Método para devolver lista de los registros
  */
 public static List <templates_tasks> fetchAll()
 {
     using (var conn = new db_entities()) {
         try {
             return(conn.templates_tasks.ToList());
         } catch (Exception e) {
             throw e;
         }
     }
 }
Example #22
0
 /**
  * Método para validar si existe el registro
  * @return true si existe
  */
 public static bool exists(String name)
 {
     using (var conn = new db_entities()) {
         try {
             var result = conn.modules.Where(x => x.name.Equals(name)).FirstOrDefault();
             return(result != null);
         } catch (Exception e) {
             throw e;
         }
     }
 }
 /**
  * Método para crear nuevo registro
  */
 public static void insert(users user)
 {
     using (var conn = new db_entities()) {
         try {
             conn.SP_USER_INSERT(user.name, user.email, user.password, user.rol_id, user.unit_id,
                                 DateTime.Now, 1);
         } catch (Exception e) {
             throw e;
         }
     }
 }
 /**
  * Método para validar si existe el registro
  * @return true si existe
  */
 public static bool exists(String email)
 {
     using (var conn = new db_entities()) {
         try {
             var result = conn.users.Where(x => x.email.Equals(email)).FirstOrDefault();
             return(result != null);
         } catch (Exception e) {
             throw e;
         }
     }
 }
        /**
         * Método para devolver lista de los registros
         */
        public static List <process> fetchAllByUnit(decimal unit_id)
        {
            using (var conn = new db_entities()) {
                try {
                    var users = conn.users.Where(x => x.unit_id == unit_id).Select(x => x.id).ToList();

                    return(conn.process.Where(r => users.Contains(r.user_id)).ToList());
                } catch (Exception e) {
                    throw e;
                }
            }
        }
 /**
  * Método para actualizar el registro
  */
 public static bool checkToken(String token)
 {
     using (var conn = new db_entities()) {
         try {
             var entity = conn.users.Where(x => x.token_session == token && x.state == 1
                                           ).FirstOrDefault();
             return(entity != null);
         } catch (Exception e) {
             throw e;
         }
     }
 }
Example #27
0
 /**
  * Método para actualizar el registro
  */
 public static void update(decimal id, String name, int state)
 {
     using (var conn = new db_entities()) {
         try {
             var entity = conn.modules.Where(x => x.id == id).FirstOrDefault();
             entity.name       = name;
             entity.state      = state;
             entity.updated_at = DateTime.Now;
             conn.SaveChanges();
         } catch (Exception e) {
             throw e;
         }
     }
 }
Example #28
0
 /**
  * Método para crear nuevo registro
  */
 public static void insert(String name)
 {
     using (var conn = new db_entities()) {
         try {
             modules entity = new modules();
             entity.name       = name;
             entity.created_at = DateTime.Now;
             entity.state      = 1;
             conn.modules.Add(entity);
             conn.SaveChanges();
         } catch (Exception e) {
             throw e;
         }
     }
 }
        public static decimal insert(string name, string description, DateTime start, decimal userId)
        {
            using (var conn = new db_entities()) {
                try {
                    conn.SP_PROCESS_INSERT(name, description, DateTime.Now, start, userId);;

                    var process = conn.process.Where(x => x.name.Equals(name) &&
                                                     x.description.Equals(description) &&
                                                     x.user_id == userId).FirstOrDefault();

                    return(process.id);
                } catch (Exception e) {
                    throw e;
                }
            }
        }
Example #30
0
        /**
         * Método para crear nuevo registro
         */
        public static void insert(String name, String description, List <templates_tasks> tasks, long userId)
        {
            using (var conn = new db_entities()) {
                try {
                    conn.SP_TEMPLATE_INSERT(name, description, DateTime.Now, 1, userId);

                    var entity = conn.templates.Where(x => x.name == name).FirstOrDefault();

                    foreach (templates_tasks tt in tasks)
                    {
                        conn.SP_TEMPLATE_TASK_INSERT(tt.name, tt.description, entity.id, tt.task_status_code, DateTime.Now, tt.end_date, userId);
                    }
                } catch (Exception e) {
                    throw e;
                }
            }
        }