/** * 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; } } }