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; } } }
/** * 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; } } }
/** * 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 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; } } }
/** * Método para iniciar sesion desde el telefono */ public static users signInMovil(String email, String pass, String token) { using (var conn = new db_entities()) { try { var entity = conn.users.Where(x => x.email == email && x.password == pass && x.rol_id == 0).FirstOrDefault(); if (entity != null) { entity.token_session = token; conn.SaveChanges(); return(entity); } else { throw new NotFoundException(); } } 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; } } }
/** * Método para actualizar el registro */ public static void update(decimal id, String name, String description, int state, List <templates_tasks> tasks, long userId) { using (var conn = new db_entities()) { try { conn.SP_TEMPLATE_UPDATE(id, name, description, DateTime.Now, state, userId); // removemos los items foreach (templates_tasks tt in conn.templates_tasks.Where(x => x.template_id == id).ToList()) { conn.templates_tasks.Remove(tt); } conn.SaveChanges(); // agregamos las actualizaciones foreach (templates_tasks tt in tasks) { conn.SP_TEMPLATE_TASK_INSERT(tt.name, tt.description, id, tt.task_status_code, DateTime.Now, tt.end_date, userId); } } 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; } } }