Пример #1
0
        public void ALamp_Add_TrueIsId1()
        {
            Producent producent = new Producent()
            {
                Naam           = "Phillips",
                Rekeningnummer = "60",
                Gemeente       = "Budel",
                Straat         = "Berk",
                Huisnummer     = "14B",
                PostCode       = "2060NJ"
            };

            producentRepository.Add(producent);


            Lamp lamp = new Lamp()
            {
                Model       = "Test",
                Watt        = 30,
                Kleur       = 30,
                Prijs       = 4,
                ProducentId = 1,
                Aantal      = 5
            };

            lampRepository.Add(lamp);
            lampRepository.Save();

            Assert.IsTrue(lampRepository.GetById(1) != null);
        }
Пример #2
0
        public async Task <IActionResult> PutProducent([FromRoute] int id, [FromBody] Producent producent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != producent.IdProducent)
            {
                return(BadRequest());
            }

            _context.Entry(producent).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProducentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Naam,Rekeningnummer,Gemeente,Straat,Huisnummer,PostCode")] Producent producent)
        {
            if (id != producent.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    producentRepository.Update(producent);
                    await producentRepository.SaveAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProducentExists(producent.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(producent));
        }
Пример #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Producent producent = db.Producents.Find(id);

            db.Producents.Remove(producent);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #5
0
        public ActionResult EditProducent(int producentId)
        {
            Producent localProducent = adminService.GetProducentById(producentId);

            return(View(new EditProducentViewModel()
            {
                ProducentName = localProducent.Name, Id = producentId
            }));
        }
Пример #6
0
 public ActionResult Edit([Bind(Include = "ProducentId,Nazwa")] Producent producent)
 {
     if (ModelState.IsValid)
     {
         db.Entry(producent).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(producent));
 }
Пример #7
0
        public ActionResult Create([Bind(Include = "ProducentId,Nazwa")] Producent producent)
        {
            if (ModelState.IsValid)
            {
                db.Producents.Add(producent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(producent));
        }
Пример #8
0
        public async Task <IActionResult> PostProducent([FromBody] Producent producent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Producent.Add(producent);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProducent", new { id = producent.IdProducent }, producent));
        }
        public async Task <IActionResult> Create([Bind("Naam,Rekeningnummer,Gemeente,Straat,Huisnummer,PostCode")] Producent producent)
        {
            if (ModelState.IsValid)
            {
                producentRepository.Add(producent);

                await producentRepository.SaveAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(producent));
        }
Пример #10
0
 private void SeedProducent(ProContext context)
 {
     for (int i = 1; i < 9; i++)
     {
         var Producent = new Producent
         {
             Id    = i,
             Nazwa = "Nazawa producenta" + i.ToString()
         };
         context.Set <Producent>().AddOrUpdate(Producent);
     }
     context.SaveChanges();
 }
Пример #11
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Producent producent = db.Producents.Find(id);

            if (producent == null)
            {
                return(HttpNotFound());
            }
            return(View(producent));
        }
Пример #12
0
        protected void btnZapisz_Click1(object sender, EventArgs e)
        {
            int            id = int.Parse(Request.QueryString["id"].ToString());
            Service1Client sc = new Service1Client();
            Producent      pr = new Producent();

            pr.Id_producent  = id;
            pr.Nazwa         = tbProducent.Text;
            pr.Zalozyciel    = tbZalozyciel.Text;
            pr.Rok_zalozenia = DateTime.Parse(tbRokZal.Text);
            sc.edytujProducenta(pr);
            sc.Close();
            Response.Redirect("Producer.aspx");
        }
Пример #13
0
 protected void btnZapisz_Click1(object sender, EventArgs e)
 {
     Page.Validate("addproducer");
     if (Page.IsValid)
     {
         Service1Client sc = new Service1Client();
         Producent      pr = new Producent();
         pr.Nazwa         = tbProducent.Text;
         pr.Zalozyciel    = tbZalozyciel.Text;
         pr.Rok_zalozenia = DateTime.Parse(tbRokZal.Text);
         sc.dodajProducenta(pr);
         sc.Close();
         Response.Redirect("~/Producer.aspx");
     }
 }
Пример #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Args"></param>
        static void Main(string[] Args)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(BaseAddress);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            //// List all products
            //var prodList = SendGet(client);

            //// Update prod
            //var changedProduct = (Product) prodList[0];
            //changedProduct.Name += " changed";
            //changedProduct.Price = 12;
            //changedProduct.CategoryID = 0;
            //changedProduct.EAN = "1234";

            //SendPut(client, changedProduct);

            //// Add prod
            //var newProd = new Product();
            //newProd.Name = "Created by client";
            //newProd.Code = "Test99";
            //newProd.CategoryID = 0;
            //newProd.Price = 11;
            //newProd.EAN = "1234";

            var newProducent = new Producent
            {
                Code  = "newProd",
                Name  = "newProd",
                Email = "*****@*****.**",
                Addr  = new Address
                {
                    Country = "Poland",
                    City    = "Lublin",
                    Street  = "Zana"
                }
            };

            SendPost(client, ProducentController, newProducent);

            // Delete prod
            //SendDelete(client, "Test99");

            Console.ReadLine();
        }
Пример #15
0
        public static void Main(string[] args)
        {
            Storage   mainStorage = new Storage(1000);
            Producent prod        = new Producent(mainStorage);
            Consumer  con1        = new Consumer(mainStorage);
            Consumer  con2        = new Consumer(mainStorage);
            Consumer  con3        = new Consumer(mainStorage);

            Console.Write("  ");
            var thr1 = new Thread(new ThreadStart(prod.Run));

            thr1.Start();

            var thr2 = new Thread(new ThreadStart(con1.Run));

            thr2.Start();
            var thr3 = new Thread(new ThreadStart(con2.Run));

            thr3.Start();
            var thr4 = new Thread(new ThreadStart(con2.Run));

            thr4.Start();
        }
Пример #16
0
        public ActionResult Save(Producent producent)
        {
            if (!ModelState.IsValid)
            {
                return(View("New", producent));
            }



            if (producent.Id == 0)
            {
                _context.Producents.Add(producent);
            }
            else
            {
                var producentdb = _context.Producents.Single(c => c.Id == producent.Id);

                producentdb.Nazwa = producent.Nazwa;
            }

            _context.SaveChanges();
            return(RedirectToAction("Index", "Producents"));
        }
Пример #17
0
        public ActionResult New()
        {
            var prod = new Producent();

            return(View(prod));
        }
Пример #18
0
 public void AddNewProducent(Producent producent)
 {
     producentRepo.Insert(producent);
 }
Пример #19
0
 public Controller()
 {
     Buffer = "";
     Producent = new Producent("abc",3);
     Consumer = new Consumer("cba");
 }
Пример #20
0
 public void EditProducent(Producent producent)
 {
     producentRepo.Update(producent);
 }