コード例 #1
0
ファイル: Program.cs プロジェクト: volkankaraali/csharpders
        static void Main(string[] args)
        {
            Product product1 = new Product();

            product1.Name        = "Elma";
            product1.Price       = 15;
            product1.Description = "Amasya Elması";

            Product product2 = new Product();

            product2.Name        = "Kapuz";
            product2.Price       = 80;
            product2.Description = "Diyarbakır Karpuzu";

            Product[] products = new Product[] { product1, product2 };

            foreach (var product in products)
            {
                Console.WriteLine(product.Name);
                Console.WriteLine(product.Price);
                Console.WriteLine(product.Description);
                Console.WriteLine("-----------------------");
            }

            Console.WriteLine("--------Metodlar---------");
            //instance-örnek
            //encapsulation
            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);

            sepetManager.Add2("Armut", "Yeşil Armut", 12);
        }
コード例 #2
0
        public ActionResult Create(Sepet sepet)
        {
            if (ModelState.IsValid)
            {
                SepetManager.Add(sepet);
                return(RedirectToAction("Index"));
            }

            return(View(sepet));
        }
コード例 #3
0
        public ActionResult Create(Siparis siparis)
        {
            var    user       = UserManager.FindByName(User.Identity.Name);
            Profil userProfil = user.Profil.LastOrDefault();

            if (ModelState.IsValid)
            {
                siparis.SiparisUrunler = sipUrunler;
                siparis.SiparisTarihi  = DateTime.Now;
                SepetManager.Add(new Sepet {
                    ProfilId = userProfil.ProfilId
                });

                SiparisManager.Add(siparis);
                return(RedirectToAction("Index"));
            }

            return(View(siparis));
        }
コード例 #4
0
        public ActionResult SepeteUrunEkle(int urunId)
        {
            Urun sepeteEklenecekUrun = UrunManager.GetById(urunId);

            var    user       = UserManager.FindByName(User.Identity.Name);
            Profil userProfil = user.Profil.LastOrDefault();
            Sepet  userSepet  = SepetManager.GetByProfilId(userProfil.ProfilId);

            if (userSepet.SepetUrun.Count == 0)
            {
                userSepet.ProfilId = userProfil.ProfilId;
                SepetManager.Add(userSepet);
            }
            SepetUrun sepetUrun = new SepetUrun {
                SepetId = userSepet.SepetId, Urun = sepeteEklenecekUrun, Miktar = 1
            };

            SepetManager.AddUrunToSepet(userSepet.SepetId, sepetUrun);

            return(RedirectToAction("Index", "Home"));
        }