コード例 #1
0
ファイル: CardBasket.cs プロジェクト: canguleer/E-commercePro
        public static bool AddProduct(int productId, int quantity, int type)
        {
            ETicaretEntities _db        = new ETicaretEntities();
            List <CartLine>  _cardLines = (List <CartLine>)HttpContext.Current.Cache["Sepet"] ?? new List <CartLine>();

            var line = _cardLines.FirstOrDefault(i => i.ProductId == productId);

            if (line == null)
            {
                var             product  = _db.Product.Where(w => w.id == productId).FirstOrDefault();
                var             ctx      = HttpContext.Current.GetOwinContext();
                ClaimsPrincipal user     = ctx.Authentication.User;
                var             identity = (ClaimsIdentity)user.Identity;
                int             userID   = 0;
                if (identity.IsAuthenticated)
                {
                    userID = Convert.ToInt32(identity.FindFirst(ClaimTypes.Sid).Value);
                }
                CartLine newline = new CartLine();
                newline.Image      = product.image;
                newline.TotalPrice = product.Price * quantity;
                newline.ProductId  = product.id;
                newline.Quantity   = quantity;
                newline.UserId     = userID;
                newline.Price      = product.Price;
                newline.Marka      = product.Brand_Model.Brand.brandName;
                newline.Model      = product.Brand_Model.Model.modelName;
                _cardLines.Add(newline);
                HttpContext.Current.Cache["Sepet"] = _cardLines;
            }
            else
            {
                CartLine newData = line;
                if (type == (int)EnumHelper.SepetEklemeTip.yeni_ekle)
                {
                    newData.Quantity   = newData.Quantity + quantity;
                    newData.TotalPrice = newData.Price * newData.Quantity;
                }
                else
                {
                    newData.Quantity   = quantity;
                    newData.TotalPrice = newData.Price * newData.Quantity;
                }
                List <CartLine> newList = new List <CartLine>();
                foreach (var item in _cardLines)
                {
                    if (item.ProductId == line.ProductId)
                    {
                        item.Quantity   = newData.Quantity;
                        item.TotalPrice = newData.TotalPrice;
                    }
                    newList.Add(item);
                }
                HttpContext.Current.Cache["Sepet"] = newList;
            }
            return(true);
        }
コード例 #2
0
 public ServiceBase(ETicaretEntities dbContext)
 {
     this.Db   = dbContext;
     _dbSet    = Db.Set <TEntity>();
     _basarili = new IslemSonucu {
         BasariliMi = true
     };
     _hatali = new IslemSonucu {
         BasariliMi = false
     };
 }
コード例 #3
0
 public CompaniesController(ETicaretEntities _db)
 {
     db = _db;
 }
コード例 #4
0
 public YoneticiServis(ETicaretEntities context)
     : base(context)
 {
 }
コード例 #5
0
 public CategoriesController(ETicaretEntities _db)
 {
     db = _db;
 }
コード例 #6
0
 public BaseController()
 {
     context = new ETicaretEntities();
     ViewBag.MenuCategories = context.Categories.Where(x => x.Parent_Id == null).ToList();
 }
コード例 #7
0
 public HomeController(I_Products prd, ETicaretEntities db)
 {
     _prd = prd;
     _db  = db;
 }
コード例 #8
0
 public ServiceBase(ETicaretEntities dbContext)
 {
     this._dbContext = dbContext;
     _dbSet          = _dbContext.Set <TEntity>();
 }
コード例 #9
0
ファイル: Helper.cs プロジェクト: canguleer/E-commercePro
 public Helper(ETicaretEntities db)
 {
     _db = db;
 }
コード例 #10
0
 public ResimServis(ETicaretEntities context) : base(context)
 {
 }
コード例 #11
0
 public UsersController(ETicaretEntities _db)
 {
     db = _db;
 }
コード例 #12
0
 public CustomersController(ETicaretEntities _db)
 {
     db = _db;
 }
コード例 #13
0
 public BrandsController(ETicaretEntities _db)
 {
     db = _db;
 }
コード例 #14
0
 public UrunServis(ETicaretEntities context) : base(context)
 {
 }
コード例 #15
0
 public ProductDetailsController(ETicaretEntities _db)
 {
     db = _db;
 }
コード例 #16
0
 public KategoriServis(ETicaretEntities context)
     : base(context)
 {
 }
コード例 #17
0
 public Products(ETicaretEntities db)
 {
     _db = db;
 }
コード例 #18
0
 public KullaniciServis(ETicaretEntities dbContext)
     : base(dbContext)
 {
 }
コード例 #19
0
 public ModelsController(ETicaretEntities _db)
 {
     db = _db;
 }
コード例 #20
0
 public LoginController()   // Entitiy ile code first yaptığımız Data base'i inşa method ile oluşturalım.
 {
     context = new ETicaretEntities();
 }
コード例 #21
0
 public AccountController(ETicaretEntities db, I_Helper hlp)
 {
     _db  = db;
     _hlp = hlp;
 }
コード例 #22
0
 public iController()
 {
     context = new ETicaretEntities();
 }
コード例 #23
0
 public ServisNoktasi()
 {
     _context = new ETicaretEntities();
 }