public async Task <Sofa> Put(Sofa updateSofa)
        {
            _context.Update(updateSofa);
            await _context.SaveChangesAsync();

            return(updateSofa);
        }
        public async Task <Sofa> Post(Sofa newSofa)
        {
            _context.Sofa.Add(newSofa);
            await _context.SaveChangesAsync();

            return(newSofa);
        }
Beispiel #3
0
        public bool UpdateSofa(Sofa sofa)
        {
            using (HorecaMebelEntities db = new HorecaMebelEntities())
            {
                var sofaFromDB = db.Sofas.FirstOrDefault(x => x.id == sofa.id);

                sofaFromDB.Name = sofa.Name;

                sofaFromDB.ImagePath = sofa.ImagePath;
                sofaFromDB.Price     = sofa.Price;

                sofaFromDB.NewPrice    = sofa.NewPrice;
                sofaFromDB.Description = sofa.Description;

                sofaFromDB.WoodenFrame = sofa.WoodenFrame;
                sofaFromDB.Seat        = sofa.Seat;
                sofaFromDB.Back        = sofa.Back;

                sofaFromDB.Width = sofa.Width;

                sofaFromDB.Height = sofa.Height;

                sofaFromDB.Depth = sofa.Depth;

                sofaFromDB.Legs = sofa.Legs;
                sofaFromDB.Skin = sofa.Skin;

                sofaFromDB.ProductionTime = sofa.ProductionTime;

                sofaFromDB.SkinColour = sofa.SkinColour;

                db.SaveChanges();
                return(true);
            }
        }
Beispiel #4
0
        public void BreakTheFurnitureSofaTest()
        {
            Sofa ff = new Sofa(f4.Name, f4.Material, f4.Color);

            f4.BreakTheFurniture();

            Assert.AreNotEqual(f4, ff);
        }
Beispiel #5
0
        public void BreakTheFurnitureBedTest()
        {
            Sofa ff = new Sofa(f5.Name, f5.Material, f5.Color);

            f5.BreakTheFurniture();

            Assert.AreNotEqual(f5, ff);
        }
        public async Task <Sofa> Delete(int id)
        {
            Sofa sofaToDelete = await _context.Sofa.FirstAsync(sofa => sofa.Id == id);

            _context.Sofa.Remove(sofaToDelete);
            await _context.SaveChangesAsync();

            return(sofaToDelete);
        }
Beispiel #7
0
    public void ToggleRecramier()
    {
        Close_all_anim_icons();

        Sofa.SetActive(false);
        Wardrobe.SetActive(false);
        Recamier.SetActive(true);
        Coffeetable.SetActive(false);
    }
Beispiel #8
0
    public void ToggleWardrobe()
    {
        Close_all_anim_icons();
        icon_anim_door_empty.SetActive(true);
        icon_anim_door_items.SetActive(true);

        Sofa.SetActive(false);
        Wardrobe.SetActive(true);
        Recamier.SetActive(false);
        Coffeetable.SetActive(false);
    }
Beispiel #9
0
        public void ComprobarLecturaYEscritura()
        {
            Sofa       sofaEscrito = new Sofa(1, 2, 3, ColorSofa.Blanco);
            ArchivoXML archivo     = new ArchivoXML();

            archivo.Guardar("Simulacro.xml", sofaEscrito);

            Sofa sofaLeido = (Sofa)archivo.Leer("Simulacro.xml");

            //Console.WriteLine("sofa 1: {0}, sofa 2 : {1}", sofa.ToString(), sofa2.ToString());
            Assert.AreEqual(sofaEscrito.alto, sofaLeido.alto);
            Assert.AreEqual(sofaEscrito.ancho, sofaLeido.ancho);
            Assert.AreEqual(sofaEscrito.profundidad, sofaLeido.profundidad);
            Assert.AreEqual(sofaEscrito.color, sofaLeido.color);
        }
Beispiel #10
0
        public void Initialising()
        {
            //_moq1 = new Mock<HomeFurniture>();
            //_moq2 = new Mock<SleepFurniture>();
            //_moq3 = new Mock<SofaBed>();
            //_moq4 = new Mock<Sofa>();
            //_moq5 = new Mock<Bed>();

            f  = new Furniture("Sofa", "Wood");
            f1 = new HomeFurniture("Chair", "Metal", "Red");
            f2 = new SleepFurniture("Chair", "Metal", "Red");
            f3 = new SofaBed("Sofa", "Wood", "Red");
            f4 = new Sofa("Chair", "Plastic", "Red");
            f5 = new Bed("Chair", "Metal", "Red");
        }
Beispiel #11
0
        // method with implemntation
        public void GetInventory()
        {
            Sofa s = new Sofa();

            // I need all tools and parts of chair

            foreach (var tools in s.GetTools())
            {
                Console.WriteLine("Tools:" + tools);
            }
            foreach (var parts in s.GetParts())
            {
                Console.WriteLine("Parts:" + parts);
            }
        }
Beispiel #12
0
 public JsonResult AddSofa(Sofa sofa)
 {
     try
     {
         if (sofa == null)
         {
             throw new Exception();
         }
         this.sofaDb.SaveSofa(sofa);
         return(Json(new { Status = true }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { Status = false, Message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #13
0
        public bool SaveSofa(Sofa sofa)
        {
            try
            {
                using (HorecaMebelEntities db = new HorecaMebelEntities())
                {
                    db.Sofas.Add(sofa);

                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            Sofa sofa1 = new Sofa();
            Sofa sofa2 = new Sofa();
            Sofa sofa3 = new Sofa();

            sofa1.InitFields("Альба", 45000, 3, 1.5f, 1);
            sofa2.InitFields("Боска", 98000, 4, 1.3f, 1.5f);
            sofa3.InitFields("Нивала", 69000, 3.5f, 1, 1.15f);

            sofa1.PrintFields();
            sofa2.PrintFields();
            sofa3.PrintFields();

            Console.WriteLine("Общее количество объектов: {0}", Sofa.count);

            Console.ReadKey();
        }
Beispiel #15
0
        public Asiento Leer(string path)
        {
            Sofa votacion = new Sofa();

            try
            {
                //ProductoA votacion = new ProductoA();
                XmlTextReader xTxtReader = new XmlTextReader(path);
                XmlSerializer xs         = new XmlSerializer(typeof(Sofa));
                votacion = (Sofa)xs.Deserialize(xTxtReader);
                xTxtReader.Close();
                return(votacion);
            }
            catch (Exception e)
            {
                // throw new ErrorArchivoException("Error al leer el archivo", e);
                throw e;
            }
        }
Beispiel #16
0
    /* F**K THE POLICE THIS IS GOOD CODE */
    public void energyUpdate()
    {
        float delta = Time.deltaTime;

        Sofa sofaPtr = currentBed as Sofa;

        if (sofaPtr != null)
        {
            if (health < 100f)
            {
                health += (100f / 20f) * Time.deltaTime;
            }
            return;
        }

        if (health <= 0f)
        {
            return;
        }

        float emptyTime = 180f;

        if (currentBed != null &&
            currentBed.patient != null &&
            currentBed.patient.IsInBed)
        {
            if (health > 0f)
            {
                // Roughly three surgeries
                emptyTime = 30f;
            }
        }
        else
        {
            if (health > 0f)
            {
                emptyTime = 60f;
            }
        }

        health -= Time.deltaTime * (100f / emptyTime);
    }
Beispiel #17
0
 public bool Guardar(string path, Asiento elemento)
 {
     try
     {
         if (elemento is Sofa)
         {
             Sofa          pA  = (Sofa)elemento;
             XmlTextWriter xw  = new XmlTextWriter(path, Encoding.UTF8);
             XmlSerializer ser = new XmlSerializer(typeof(Sofa));
             ser.Serialize(xw, pA);
             xw.Close();
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
         // throw new ErrorArchivoException("Error al guardar el archivo", e);
         throw e;
     }
 }
 public Lugar()
 {
     par     = new Pared[7];
     par[0]  = new Pared(new Point3D(0, 7.5, -40), 0, 40);
     par[1]  = new Pared(new Point3D(-20, 7.5, -20), 90, 40);
     par[2]  = new Pared(new Point3D(20, 7.5, -20), 90, 40);
     par[3]  = new Pared(new Point3D(0, 15, -20), 0, 50, 1, 42, 7);
     par[4]  = new Pared(new Point3D(0, 0, -20), 0, 42, 1, 42, 6);
     par[5]  = new Pared(new Point3D(-14.5, 3.5, 0), 0, 2.5, 0.3, 1, 8);
     par[6]  = new Pared(new Point3D(-11.5, 3.5, 0), 0, 2.5, 0.3, 1, 8);
     cuad    = new Cuadro[3];
     cuad[0] = new Cuadro(new Point3D(-18.5, 7, -25), 5, 3, 90, 10, 7);
     cuad[1] = new Cuadro(new Point3D(-10, 7, -38.5), 7, 4, 0, 11, 8);
     cuad[2] = new Cuadro(new Point3D(10, 7, -38.5), 7, 3, 0, 12, 7);
     bur     = new Buro(new Point3D(-13, 3, -22), 6, 3.5, 8);
     sil     = new Silla(new Point3D(-16, 4, -21), 2, 2, 2, new float[] { 0.3f, 0.2f, 0f }, new float[] { 0.4f, 0f, 0f });
     m       = new Mata();
     sof     = new Sofa();
     bas     = new Base111(new Point3D(0, -1.3, -20), 7, new float[] { 1.0f, 0.4f, 0.2f, 1.0f });
     this.Recompile();
 }
Beispiel #19
0
 public Lugar()
 {
     par=new Pared[7];
         par[0]=new Pared(new Point3D(0,7.5,-40),0,40);
         par[1]=new Pared(new Point3D(-20,7.5,-20),90,40);
         par[2]=new Pared(new Point3D(20,7.5,-20),90,40);
         par[3]=new Pared(new Point3D(0,15,-20),0,50,1,42,7);
         par[4]=new Pared(new Point3D(0,0,-20),0,42,1,42,6);
         par[5]=new Pared(new Point3D(-14.5,3.5,0),0,2.5,0.3,1,8);
         par[6]=new Pared(new Point3D(-11.5,3.5,0),0,2.5,0.3,1,8);
         cuad=new Cuadro[3];
         cuad[0]=new Cuadro(new Point3D(-18.5,7,-25),5,3,90,10,7);
         cuad[1]=new Cuadro(new Point3D(-10,7,-38.5),7,4,0,11,8);
         cuad[2]=new Cuadro(new Point3D(10,7,-38.5),7,3,0,12,7);
         bur=new Buro(new Point3D(-13,3,-22),6,3.5,8);
         sil=new Silla(new Point3D(-16,4,-21),2,2,2,new float[]{0.3f,0.2f,0f},new float[]{0.4f,0f,0f});
         m=new Mata();
         sof=new Sofa();
         bas=new Base111(new Point3D(0,-1.3,-20),7,new float[]{1.0f,0.4f,0.2f,1.0f});
         this.Recompile();
 }
Beispiel #20
0
 public void PerformOrder()
 {
     Debug.Log("Performing order!");
     if (_order.objectAction.GetType() == typeof(Bed) || _order.objectAction.GetType() == typeof(OrBed) || _order.objectAction.GetType() == typeof(Sofa))
     {
         Debug.LogWarning("Start " + this.ToString());
         foreach (Clickable actor in _order.actors)
         {
             if (actor.GetType() == typeof(Nurse) && (_order.objectAction != null) && (_order.objectAction as Bed).nurse == null)
             {
                 Bed bed = _order.objectAction as Bed;
                 bed.nurse = actor as Nurse;
                 actor.BeginPerform(_order);
                 Debug.Log("***********************************************************");
             }
             else if (actor.GetType() == typeof(Surgeon) && _order.objectAction != null)
             {
                 if (_order.objectAction.GetType() == typeof(Sofa) && (_order.objectAction as Sofa).surgeon == null)
                 {
                     Sofa sofa = _order.objectAction as Sofa;
                     sofa.surgeon = actor as Surgeon;
                     actor.BeginPerform(_order);
                 }
                 else if (order.objectAction.GetType() == typeof(OrBed) && (_order.objectAction as OrBed).surgeon == null)
                 {
                     OrBed orBed = _order.objectAction as OrBed;
                     orBed.surgeon = actor as Surgeon;
                     actor.BeginPerform(_order);
                 }
             }
         }
         if (order.subject != null && (_order.objectAction as Bed) != null && _order.objectAction.GetType() != typeof(Sofa) && (_order.objectAction as Bed).patient == null)
         {
             Bed bed = _order.objectAction as Bed;
             bed.patient = order.subject as Patient;
             order.subject.BeginPerform(_order);
         }
     }
 }
Beispiel #21
0
        static void Main(string[] args)
        {
            // error -- IRunner i1 = new IRunner();

            IRunner i1 = new SportMan("dudi");


            Sofa s = new Sofa();

            PaintFurn(s);
            Fence f = new Fence();

            // error: PaintFurn(f);
            PaintIPaint(f);

            Circle c = new Circle();

            Draw3D(c);
            Person p = new Person();
            // Draw3D(p);

            SportMan sportMan = new SportMan("nahum");

            sportMan.Run();
            sportMan.GetName();
            sportMan.ToString();

            IRunner runner = sportMan;

            // object
            // Run (IRunner)
            runner.Run();

            object sp_obj     = sportMan;
            object circle_obj = c;
        }
Beispiel #22
0
 public AbstractFactoryClient(FurnitureFactory factory)
 {
     _chair = factory.CreateChair();
     _sofa  = factory.CreateSofa();
     _table = factory.CreateTable();
 }
 /// <summary>
 /// This method can be omitted in our example
 /// </summary>
 /// <param name="sofa"></param>
 public abstract void Interact(Sofa sofa);
 public override void Interact(Sofa sofa)
 {
     Console.WriteLine($"Interaction between: {GetType().Name} and {sofa.GetType().Name}");
 }
Beispiel #25
0
 public FurnitureClient(Chair chair, Sofa sofa, CoffeeTable coffeeTable)
 {
     _chair       = chair;
     _sofa        = sofa;
     _coffeeTable = coffeeTable;
 }
Beispiel #26
0
 public void setSofa(Sofa sofa)
 {
     this.sofa = sofa;
 }
Beispiel #27
0
        static void Main(string[] args)
        {
            rand = new Random(DateTime.Now.Millisecond);
            Furniture[] furnitures = new Furniture[4];
            Sofa        sofa       = new Sofa("Sofa", 200, 1.1f, 0.5f, 2.3f, 500);
            Bed         bed        = new Bed("Bed", 100, 0.8f, 0.5f, 2.1f, 600);
            Chair       chair      = new Chair("Chair", 30, 0.7f, 1.2f, 0.7f, 456);
            Table       table      = new Table("Table", 40, 0.9f, 1.1f, 1.6f, 400);

            sofa.Print();
            Console.WriteLine($"|{sofa.Name}\t|{sofa.Weight}\t|{sofa.Width}\t|{sofa.Height}\t|{sofa.Length}\t|{sofa.Price}");
            Console.WriteLine($"|{bed.Name}\t|{bed.Weight}\t|{bed.Width}\t|{bed.Height}\t|{bed.Length}\t|{bed.Price}");
            Console.WriteLine($"|{chair.Name}\t|{chair.Weight}\t|{chair.Width}\t|{chair.Height}\t|{chair.Length}\t|{chair.Price}");
            Console.WriteLine($"|{table.Name}\t|{table.Weight}\t|{table.Width}\t|{table.Height}\t|{table.Length}\t|{table.Price}");
            Console.WriteLine($"\n");
            Console.WriteLine($"\nИнтерфейс:");
            sofa.sell();
            bed.sell();
            chair.sell();
            table.sell();
            Console.WriteLine($"\nИнтерфейс + Абстрактный класс:");
            sofa.sold();
            Console.WriteLine($"\n");

            Sofa sofa1 = sofa as Sofa;

            Console.WriteLine($"\n\nЛабораторная работа №6\n\n");
            try
            {
                int Type = 2;
                int y;
                y = Type / 0;
            }
            catch (DivideByZeroException)
            {
                Console.WriteLine("Возникло исключение DivideByZeroException");
            }
            try
            {
                object n = "Hello";
                int    s = (int)n;
            }
            catch (NotType ex)
            {
                ex.ToString().ToLog();
            }
            try
            {
                string str = "Hello";
                str = str.Insert(1, "World");
                throw new OutOfMemoryException();
            }
            catch (OutOfMemoryException str)
            {
                Console.WriteLine($"Возникло исключение OutOfMemoryException");
            }
            try
            {
                string n = null;
            }
            catch (NotCreate n)
            {
                n.ToString().ToLog();
            }
            finally
            {
                Console.WriteLine($"Вроде словил...");
            }
            Debug.Assert(sofa != null, "Got a null");
        }
Beispiel #28
0
        /// <summary>
        /// Primer Parcial: Agregar el elemento a la mueblería.
        /// Segundo Parcial y Final: Al presionar el botón agregar se deberá guardar la información a un archivo, anexando el nuevo Asiento al final. Agregar el elemento a la lista.
        /// Luego, leer el archivo y mostrarlo en el RichTextBox.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            #region Crear un sofa
            Sofa unSofa = new Sofa();
            unSofa.alto  = (short)nudAlto.Value;
            unSofa.ancho = (short)nudAncho.Value;

            Random ram = new Random();
            int    devuelveRam;
            devuelveRam = ram.Next(0, 4);
            switch (devuelveRam)
            {
            case 0:
                unSofa.color = Sofa.Color.Blanco;
                break;

            case 1:
                unSofa.color = Sofa.Color.Natural;
                break;

            case 2:
                unSofa.color = Sofa.Color.Negro;
                break;

            case 3:
                unSofa.color = Sofa.Color.Rojo;
                break;

            default:
                break;
            }
            #endregion

            #region Guardar en TXT y agregar a la lista

            try
            {
                //TextWriter WriteFileStream = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments));
                string ruta = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + "GuardoTXT.txt";
                IArchivos <string, string> archivoTXT = new ArchivoTexto();

                archivoTXT.Guardar(ruta, unSofa.ToString());


                this.listaAsientos.Add(unSofa);
            }
            catch (PathTooLongException excep)
            {
                MessageBox.Show(excep.Message);
            }


            #endregion

            #region Leer desde txt y actualizo richtextbox
            try
            {
                string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + "GuardoTXT.txt";
                IArchivos <string, string> archivoTXT = new ArchivoTexto();

                rtbMensaje.Text = archivoTXT.Leer(path);
            }
            catch (FileNotFoundException excep)
            {
                MessageBox.Show(excep.Message);
            }

            #endregion
        }
Beispiel #29
0
        private void GenerateButton_Click(object sender, EventArgs e)
        {
            // checken if product type is chosen.
            if (comboBox1.Text == "Selecteer soort")
            {
                MessageBox.Show("Er moet een soort worden aangegeven.", "Foutmelding", MessageBoxButtons.OK);
            }
            // Checking if boxes are filled.
            else if (NameBox.Text == "" || DescriptionBox.Text == "" || WidthBox.Text == "" || HeigthBox.Text == "" || PriceBox.Text == "")
            {
                MessageBox.Show("Alle velden moeten ingevuld zijn.", "Foutmelding", MessageBoxButtons.OK);
            }
            // Checking if lightbox is filled (only when product type is "Lamp").
            else if (comboBox1.SelectedItem.ToString() == "Lamp" && LightBox.Text == "")
            {
                MessageBox.Show("Alle velden moeten ingevuld zijn.", "Foutmelding", MessageBoxButtons.OK);
            }
            // Cheching if a image is uploaded.
            else if (image == null)
            {
                MessageBox.Show("Er moet een afbeelding worden meegegeven.", "Foutmelding", MessageBoxButtons.OK);
            }
            else
            {
                // Generate path project is based in.
                string workingPath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()));
                workingPath = Path.Combine(workingPath, "ProductImages");
                // Make the directory "ProductImages" if it doesnt exist.
                if (!Directory.Exists(workingPath))
                {
                    Console.WriteLine("Directory doesnt exist!");
                    Directory.CreateDirectory(workingPath);
                }
                // Move image if directory exists.
                if (Directory.Exists(workingPath))
                {
                    // Make unique image name so it doesnt overwrite
                    imageName = $@"{DateTime.Now.Ticks.GetHashCode().ToString("x").ToUpper()}.png";
                    // Copy the file to the base of this program.
                    string tempString = Path.Combine(workingPath, imageName);
                    Console.WriteLine(tempString);
                    pictureBox1.Image.Save(tempString);
                    Console.WriteLine("Directory exists!");
                }
                Product product = null;
                var     mc      = new MyContext();
                using (mc)
                {
                    // Checks the selected product type and adds that product to the database.
                    switch (comboBox1.SelectedItem.ToString())
                    {
                    case "Bank":
                        mc.products.Add(product = new Sofa(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;

                    case "Lamp":
                        mc.products.Add(product = new Lamp(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName, Int32.Parse(LightBox.Text)));
                        mc.SaveChanges();
                        break;

                    case "Essentiële":
                        mc.products.Add(product = new Essentials(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;

                    case "Stoel":
                        mc.products.Add(product = new Chair(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;

                    case "Plant":
                        mc.products.Add(product = new Plant(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;

                    case "Tafel":
                        mc.products.Add(product = new Table(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;

                    case "Wandaccesoire":
                        mc.products.Add(product = new WallAccessories(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;

                    case "Kast":
                        mc.products.Add(product = new Closet(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;
                    }
                }
                if (product == null)
                {
                    Console.WriteLine("Toegevoegd product == null");
                }
                else
                {
                    Console.WriteLine("Toegevoegd product active: " + product.active);
                }
                catalogPanel.catalogController.AddProductToVanillaList(product);
                catalogPanel.catalogController.RefreshDisplayedItems();
                MessageBox.Show("Het product is toegevoegd aan de catalogus.", "Succes", MessageBoxButtons.OK);
                Close();
            }
        }
Beispiel #30
0
 public Room(FurnitureFactory factory)
 {
     chair      = factory.CreateChair();
     sofa       = factory.CreateSofa();
     coffeTable = factory.CreateСoffeTable();
 }