Esempio n. 1
0
        public void updateResource(string path, List <string> atr)
        {
            // save button
            string name, desc;

            using (Model1Container1 context = new Model1Container1())
            {
                var b = context.atributes.Where(x => x.resource.path == path).Select(x => x);
                foreach (var i in b)
                {
                    context.atributes.Remove(i);
                }
                var id = context.resources.Where(x => x.path == path).Select(x => x.resID);

                for (var i = 0; i < atr.Count; i += 2)
                {
                    name = atr[i];
                    desc = atr[i + 1];

                    atributes a = new atributes()
                    {
                        name            = name,
                        description     = desc,
                        resources_resID = id.First()
                    };
                    context.atributes.Add(a);
                }
                context.SaveChanges();
            }
        }
Esempio n. 2
0
        public void saveResources(string path, string type, List <string> atr)
        {
            // save button
            string name, desc;

            using (Model1Container1 context = new Model1Container1())
            {
                resources r = new resources()
                {
                    path     = path,
                    added_at = DateTime.Now.ToString(),
                    type     = type
                };
                context.resources.Add(r);
                for (var i = 0; i < atr.Count; i += 2)
                {
                    name = atr[i];
                    desc = atr[i + 1];

                    atributes a = new atributes()
                    {
                        name        = name,
                        description = desc,
                        resource    = r
                    };
                    context.atributes.Add(a);
                }
                context.SaveChanges();
            }
        }
        static void Main()
        {
            dineroManager din = new dineroManager();

            /* string si; = utility[0]
             * string si_ = ""; = utility[1]
             */

            string[]  utility = new string[5];
            atributes atr     = new atributes();

            Console.WriteLine("Bienvenido a la registradora de dinero.\nPorfavor inserte su nombre");
            atr.NamePerson = Console.ReadLine();
            Console.WriteLine("Desea agregar informacion adicional? Responda con un si o no");
            utility[0] = Console.ReadLine();
            while (utility[1] != "no")
            {
                if (utility[0] == "si")
                {
                    Console.WriteLine(
                        "Inserte su apellido"); atr.Apellido = Console.ReadLine(); Console.WriteLine("Inserta tu edad");
                    atr.Edad = Console.Read();
                    Console.WriteLine("Informacion procesada, Correctamente...\n");
                    Console.WriteLine("Desea volver a llenar cambios otra vez?");
                    utility[0] = Console.ReadLine(); utility[0] = Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("Ok."); utility[1] = "no";
                }
            }
            while (utility[2] != "salir")
            {
message:
                Console.WriteLine("Que desea hacer? (Ver Dinero actual (res) , Insert , pull , salir?)");;
                utility[3] = Console.ReadLine();
                switch (utility[3])
                {
                case "insert":
                    Console.WriteLine("Cuando dinero desea insertar?");
                    int valueForInsert; string valueInsert = Console.ReadLine();
                    valueForInsert = Int32.Parse(valueInsert);
                    din.insert(valueForInsert);
                    break;

                case "pull":
                    if (din.showTotal() == 0)
                    {
                        Console.WriteLine("No hay dinero. Porfavor haga insert antes de.");
                    }
                    else
                    {
                        Console.WriteLine("Cuanto dinero desea sacar?");
                        int valueForPull; string valueforPull = Console.ReadLine();
                        valueForPull = Int32.Parse(valueforPull);
                        din.pull(valueForPull);
                    }
                    break;

                case "res":
                    Console.WriteLine(din.showTotal() == 0 ? "No tiene dinero. Haga un insert primero antes de." : "Dinero {0}", din.showTotal());
                    break;

                case "":
                    goto message;

                case "salir": utility[2] = "salir"; Console.WriteLine("Presiona cualquier tecla para salir."); Console.ReadKey(); break;

                default:
                    Console.WriteLine("Comando no encontrado.");
                    break;
                }
            }
        }