public void ExecuteEntity()
        {
            DateTime      time;
            string        equip;
            List <string> prms = new List <string>();

            prms = ListFreeEquipDateInfo(prms);
            try
            {
                time  = Convert.ToDateTime(prms[0]);
                equip = prms[1];
            }

            catch (FormatException)
            {
                Console.WriteLine("Some parameters were invalid!!");
                return;
            }

            using (var ctx = new AenimaEntities())
            {
                var equips = ctx.ListFreeEquipments(time, equip).ToList();
                ctx.SaveChanges();

                var columns = typeof(ListFreeEquipments_Result).GetProperties().Select(prop => prop.Name).ToList();

                DataUtils.PrintColumnNames(columns);

                equips.ForEach(eq => Console.WriteLine(eq.equipment_name + " - " + eq.code));

                Console.WriteLine("Listed sucessfully the free equipments");
            }
        }
        public void ExecuteEntity()
        {
            List <string> prms = new List <string>();
            int           serial_nr, price, time;
            DateTime      validity;

            prms = UpdateRentPriceInfo(prms);
            string equipType = prms[0];

            try
            {
                serial_nr = Convert.ToInt32(prms[1]);
                validity  = Convert.ToDateTime(prms[2]);
                price     = Convert.ToInt32(prms[3]);
                time      = Convert.ToInt32(prms[4]);
            }
            catch (FormatException)
            {
                Console.WriteLine("Invalid parameters !!");
                return;
            }

            using (var ctx = new AenimaEntities())
            {
                ctx.UpdateRentPrice(equipType, serial_nr, validity, price, time);
                ctx.SaveChanges();
            }
            Console.WriteLine("Sucessfully updated rent Price!");
        }
        public void ExecuteEntity()
        {
            Console.WriteLine("Insert id of the promotion you want to remove");
            int id = Convert.ToInt32(Console.ReadLine());

            using (var ctx = new  AenimaEntities())
            {
                var prom = ctx.Promotions.SingleOrDefault(x => x.id == id);

                ctx.Promotions.Remove(prom);
                ctx.SaveChanges();

                Console.WriteLine("Sucessfull remove promotion with id -> {0}", id);
            }
        }
        public void ExecuteEntity()
        {
            List <string> prms = new List <string>();

            prms = InsertRentClientInfo(prms);

            int    rentTime, rentPrice, equipCode, empNumber, nif;
            string clientName, address;

            try
            {
                rentTime  = Convert.ToInt32(prms[0]);
                rentPrice = Convert.ToInt32(prms[1]);
                equipCode = Convert.ToInt32(prms[2]);
                empNumber = Convert.ToInt32(prms[3]);
                nif       = Convert.ToInt32(prms[5]);
            }
            catch (FormatException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Some parameters were wrong...");
                return;
            }
            clientName = prms[4];
            address    = prms[6];

            var serial_nr  = new ObjectParameter("serial_nr", typeof(Int32));
            var clientCode = new ObjectParameter("clientCode", typeof(Int32));

            using (var ctx = new AenimaEntities())
            {
                try
                {
                    ctx.InsertRentAndClient(rentTime, rentPrice, equipCode, empNumber, clientName, nif, address, serial_nr, clientCode);
                    ctx.SaveChanges();
                }catch (Exception e)
                {
                    Console.WriteLine(e.InnerException.Message);
                    return;
                }
                Console.WriteLine("Sucessfull insert Rent with id {0} and client with id {1}", serial_nr.Value, clientCode.Value);

                Console.WriteLine();
            }
        }
Ejemplo n.º 5
0
        public void ExecuteEntity()
        {
            Console.WriteLine("Delete Rent:");

            Console.WriteLine("Insert the rent id you want to delete:");
            int serial_nr = Convert.ToInt32(Console.ReadLine());

            using (var ctx = new AenimaEntities())
            {
                try
                {
                    ctx.DeleteRent(serial_nr);
                    ctx.SaveChanges();
                }catch (Exception e)
                {
                    Console.WriteLine(e.InnerException.Message);
                    return;
                }
                Console.WriteLine("Sucessfull deleted rent with id {0}", serial_nr);
            }
        }
        public void ExecuteEntity()
        {
            DateTime      begin_date, end_date;
            int           id;
            List <string> prms = new List <string>();

            prms = UpdatePromoInfo(prms);

            try
            {
                id         = Convert.ToInt32(prms[0]);
                begin_date = Convert.ToDateTime(prms[1]);
                end_date   = Convert.ToDateTime(prms[2]);
            }
            catch (FormatException)
            {
                Console.WriteLine("Invalid parameters inserted ...");
                return;
            }
            string descript = prms[3];

            using (var ctx = new AenimaEntities())
            {
                var promo = ctx.Promotions.SingleOrDefault(pr => pr.id == id);
                if (promo != null)
                {
                    promo.begin_date = begin_date;
                    promo.end_date   = end_date;
                    promo.descript   = descript;
                    ctx.SaveChanges();

                    Console.WriteLine("Sucessfull update promotion!");
                }
                else
                {
                    Console.WriteLine("No promotion found with that id!");
                }
            }
        }
Ejemplo n.º 7
0
        public void ExecuteEntity()
        {
            DateTime?begin_date, end_date;

            try
            {
                Console.WriteLine("Insert begin date of the promotion.");
                begin_date = Convert.ToDateTime(Console.ReadLine());

                Console.WriteLine("Insert end date of the promotion.");
                end_date = Convert.ToDateTime(Console.ReadLine());
            }
            catch (FormatException)
            {
                Console.WriteLine("Invalid date, try YYYY/MM/DD OR DD/MM/YYYY");
                return;
            }

            Console.WriteLine("Insert the description of the promotion.");
            string description = Console.ReadLine();

            using (var ctx = new AenimaEntities())
            {
                var promo = new Promotion();
                promo.begin_date = begin_date;
                promo.end_date   = end_date.Value;
                promo.descript   = description;
                ctx.Promotions.Add(promo);

                ctx.SaveChanges();

                int id = promo.id;

                Console.WriteLine("Sucessfull inserted new Promotion with id = {0}", id);
            }
        }