Пример #1
0
        static void CreateDetail(int time, int recurso, int tarea)
        {
            var ctx = new TareasDbContext();

            ctx.Set <Detalle>().Add(new Detalle
            {
                Fecha     = DateTime.Now,
                Tiempo    = time,
                RecursoId = recurso,
                TareaId   = tarea
            });

            ctx.SaveChanges();
        }
Пример #2
0
        public static void InsertDetail(DateTime date, int time, Resource resource, Task task)
        {
            var ctx = new TareasDbContext();

            ctx.Details.Add(new Detail
            {
                Date       = date,
                Time       = time,
                ResourceId = resource.Id,
                TaskId     = task.Id
            });

            ctx.SaveChanges();
        }
Пример #3
0
        static void UpdateTaskResource(int id, int resp)
        {
            var ctx   = new TareasDbContext();
            var tarea = ctx.Tareas.Where(i => i.Id == id).FirstOrDefault();

            if (tarea is null)
            {
                Console.WriteLine("La tarea no existe");
            }
            else
            {
                tarea.RecursoId = resp;
            }
            ctx.SaveChanges();
        }
Пример #4
0
        static void UpdateTaskStatus(int id, string sta)
        {
            var ctx   = new TareasDbContext();
            var tarea = ctx.Tareas.Where(i => i.Id == id).FirstOrDefault();

            if (tarea is null)
            {
                Console.WriteLine("La tarea no existe");
            }
            else
            {
                tarea.Estado = sta;
            }
            ctx.SaveChanges();
        }
Пример #5
0
        static void CreateTask(string titulo, string vencimiento, int estimacion, int responsable, string estado = null)
        {
            var ctx = new TareasDbContext();

            ctx.Set <Tarea>().Add(new Tarea
            {
                Titulo      = titulo,
                Vencimiento = DateTime.Parse(vencimiento),
                Estimacion  = estimacion,
                RecursoId   = responsable,
                Estado      = estado
            });

            ctx.SaveChanges();
        }
Пример #6
0
        public static void UpdateDetailsId(int id, DateTime date, int time, Resource resource, Task task)
        {
            var ctx = new TareasDbContext();

            var detail = ctx.Details.Where(i => i.Id == id).FirstOrDefault();

            if (detail != null)
            {
                detail.Date       = date;
                detail.Time       = time;
                detail.ResourceId = resource.Id;
                detail.TaskId     = task.Id;
            }
            ctx.SaveChanges();
        }
Пример #7
0
        public static void InsertTask(string title, DateTime expiration, int estimate, string state, Resource liable)
        {
            var ctx = new TareasDbContext();

            ctx.Tasks.Add(new Task
            {
                Title      = title,
                Expiration = expiration,
                Estimate   = estimate,
                State      = state,
                ResourceId = liable.Id
            });

            ctx.SaveChanges();
        }
Пример #8
0
        public static void Delete(int Id)
        {
            var ctx  = new TareasDbContext();
            var user = ctx.Users.Where(i => i.Id == Id).FirstOrDefault();

            if (user != null)
            {
                ctx.Users.Remove(user);
                Console.WriteLine($"Se removio el usuario con exito");
                ctx.SaveChanges();
            }
            else
            {
                Console.WriteLine($"Usuario Inexistente. ");
            }
        }
Пример #9
0
        public static void UpdateTaskId(int id, string title, DateTime expiration, int estimate, string state, Resource liable)
        {
            var ctx = new TareasDbContext();

            var task = ctx.Tasks.Where(i => i.Id == id).FirstOrDefault();

            if (task != null)
            {
                task.Title      = title;
                task.Expiration = expiration;
                task.Estimate   = estimate;
                task.State      = state;
                task.ResourceId = liable.Id;
            }
            ctx.SaveChanges();
        }
Пример #10
0
        static void ResetPasswordUser(int id, string pass = null)
        {
            var ctx     = new TareasDbContext();
            var usuario = ctx.Usuarios.Where(i => i.UsuarioPK == id).FirstOrDefault();

            if (usuario is null)
            {
                Console.WriteLine("El usuario no existe");
            }
            else
            {
                if (!string.IsNullOrEmpty(pass))
                {
                    usuario.Clave = pass;
                }
            }
            ctx.SaveChanges();
        }
Пример #11
0
        static void UpdateDetailTask(int id, int taskId)
        {
            var ctx     = new TareasDbContext();
            var detalle = ctx.Detalles.Where(i => i.Id == id).FirstOrDefault();

            if (detalle is null)
            {
                Console.WriteLine("El detalle no existe");
            }
            else
            {
                detalle.Fecha = DateTime.Now;

                if (taskId > 0)
                {
                    detalle.TareaId = taskId;
                }
            }
            ctx.SaveChanges();
        }
Пример #12
0
        static void UpdateTaskTime(int id, string venc, int est = -1)
        {
            var ctx   = new TareasDbContext();
            var tarea = ctx.Tareas.Where(i => i.Id == id).FirstOrDefault();

            if (tarea is null)
            {
                Console.WriteLine("La tarea no existe");
            }
            else
            {
                tarea.Vencimiento = DateTime.Parse(venc);

                if (est > 0)
                {
                    tarea.Estimacion = est;
                }
            }
            ctx.SaveChanges();
        }
Пример #13
0
        static void UpdateResource(int id, string name, int user = -1)
        {
            var ctx     = new TareasDbContext();
            var recurso = ctx.Recursos.Where(i => i.Id == id).FirstOrDefault();

            if (recurso is null)
            {
                Console.WriteLine("El recurso no existe");
            }
            else
            {
                if (!string.IsNullOrEmpty(name))
                {
                    recurso.Nombre = name;
                }
                if (user > 0)
                {
                    recurso.UsuarioId = user;
                }
            }
            ctx.SaveChanges();
        }