예제 #1
0
 protected override void DisposeCore()
 {
     if (dataContext != null)
     {
         dataContext.Dispose();
     }
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
예제 #3
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             DBEntity.Dispose();
         }
     }
     this.disposed = true;
 }
예제 #4
0
        public ActionResult Index(string searchKey = "")
        {
            ViewBag.searchKey = searchKey;
            List <Search_Result> Sr = new List <Search_Result>();
            // Searching from PRoduct table
            var model = new List <Product>();

            if (searchKey == "")
            {
                model = _context.Product.ToList();
            }
            else
            {
                model = _context.Product.Where(x => x.ProductName.Contains(searchKey)).ToList();
            }
            foreach (var item in model)
            {
                Search_Result sr = new Search_Result();
                sr.Price        = item.Price; sr.ProductId = item.ProductId;
                sr.ProductImage = item.ProductImage; sr.ProductName = item.ProductName;
                sr.Description  = item.Description; sr.CategoryName = _context.Category.FirstOrDefault(x => x.CategoryId == item.CategoryId).CategoryName;
                Sr.Add(sr);
            }

            //Now searching from category table


            int count = _context.Category.Count(x => x.CategoryName.Contains(searchKey));

            if (count > 0)
            {
                int Catid = _context.Category.FirstOrDefault(x => x.CategoryName.Contains(searchKey)).CategoryId;

                model = _context.Product.Where(x => x.CategoryId == Catid).ToList();
                foreach (var item in model)
                {
                    Search_Result sr = new Search_Result();
                    sr.Price        = item.Price; sr.ProductId = item.ProductId;
                    sr.ProductImage = item.ProductImage; sr.ProductName = item.ProductName;
                    sr.Description  = item.Description; sr.CategoryName = _context.Category.FirstOrDefault(x => x.CategoryId == item.CategoryId).CategoryName;
                    Sr.Add(sr);
                }
            }

            _context.Dispose();
            //List<Search_Result> sr = _unitOfWork.GetRepositoryInstance<Search_Result>().GetResultBySqlProcedure("USP_Search @searchKey", new SqlParameter("searchKey", SqlDbType.VarChar) { Value = searchKey }).ToList();
            return(View(Sr));
        }
예제 #5
0
        public IActionResult SaveRegistration(string name, string surname, DateTime birthdate, int cityID, string adresa, string email, string password, int genderID)
        {
            OnlineShopContext _database = new OnlineShopContext();

            User user = new User
            {
                Name      = name,
                Surname   = surname,
                BirthDate = birthdate,
                CityID    = cityID,
                Adress    = adresa,
                Email     = email,
                Password  = password,
                GenderID  = genderID,
            };


            _database.user.Add(user);
            _database.SaveChanges();
            _database.Dispose();
            return(Redirect("RegistrationSuccessful"));
        }
예제 #6
0
 public void Dispose()
 {
     _context.Dispose();
 }
 protected void Dispose(bool disposing)
 {
     _db.Dispose();
 }