public ActionResult Create() { var user = UserManager.FindByName(User.Identity.Name); Profil userProfil = user.Profil.LastOrDefault(); List <SepetUrun> sepetUrunler = SepetManager.GetByProfilId(userProfil.ProfilId).SepetUrun.ToList(); List <SiparisUrun> siparisUrunler = new List <SiparisUrun>(); foreach (var item in sepetUrunler) { SiparisUrun su = new SiparisUrun { UrunId = item.Urun.Id, UrunAdi = item.Urun.UrunAdi, UrunFiyati = item.Urun.UrunFiyati, UrunMiktar = item.Miktar }; siparisUrunler.Add(su); } Siparis yeniSiparis = new Siparis { ProfilId = userProfil.ProfilId, SiparisUrunler = siparisUrunler }; sipUrunler = siparisUrunler; return(View(yeniSiparis)); }
public ActionResult SepetPartial() { var user = UserManager.FindByName(User.Identity.Name); if (user == null) { return(PartialView(new Sepet())); } Profil userProfil = user.Profil.LastOrDefault(); Sepet userSepet = SepetManager.GetByProfilId(userProfil.ProfilId); return(PartialView(userSepet)); }
public ActionResult SepettenUrunCikar(int urunId) { var user = UserManager.FindByName(User.Identity.Name); Profil userProfil = user.Profil.LastOrDefault(); Sepet userSepet = SepetManager.GetByProfilId(userProfil.ProfilId); if (userSepet.SepetUrun.Count == 0) { RedirectToAction("Index", "Sepet"); } else { SepetManager.RemoveUrunFromSepet(userSepet.SepetId, urunId); } return(RedirectToAction("Index", "Sepet")); }
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")); }