Пример #1
0
        public void SaveProducts(List <Product> products)
        {
            ImeshmaEntities _db = new ImeshmaEntities();

            _db.Products.AddRange(products);
            _db.SaveChanges();
        }
Пример #2
0
        public List <Product> GetProductDetails()
        {
            List <Product> _productList;

            try
            {
                using (_db = new ImeshmaEntities())
                {
                    DbDataReader _reader;
                    //_db.Database.Initialize(force: false);
                    _db.Database.Connection.Open();
                    DbCommand _dbCmd = _db.Database.Connection.CreateCommand();
                    _dbCmd.CommandText    = "GetProductDetails";
                    _dbCmd.CommandType    = CommandType.StoredProcedure;
                    _dbCmd.CommandTimeout = 60 * 5;
                    //_dbCmd.Parameters.AddRange(new SqlParameter[] {
                    //     new SqlParameter("@Drugname",DrugName ),
                    //     new SqlParameter("@CountryId",CountryId ),
                    //     new SqlParameter("@UserId",UserID ),
                    //         new SqlParameter("@IsMedicine",IsMedicine)


                    //});
                    _reader = _dbCmd.ExecuteReader();

                    _productList = ((IObjectContextAdapter)_db).ObjectContext.Translate <Product>(_reader).ToList();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                //if (_db.Database.Connection.State == ConnectionState.Open)
                //{
                //    _db.Database.Connection.Close();
                //}
            }

            return(_productList);
        }
Пример #3
0
        public void AddUser(UserModel model)
        {
            try
            {
                ImeshmaEntities _db = new ImeshmaEntities();
                _db.Users.Add(
                    new User()
                {
                    FirstName    = model.FirstName,
                    LastName     = model.LastName,
                    Email        = model.Email,
                    CreatedDate  = DateTime.UtcNow,
                    ModifiedDate = DateTime.UtcNow,
                    LoginVia     = model.LoginVia
                }
                    );

                _db.SaveChanges();
            }
            catch
            {
                throw;
            }
        }
Пример #4
0
        // GET: Products
        public ActionResult Index()
        {
            ImeshmaEntities _db = new ImeshmaEntities();

            return(View(_db.GetProductDetails(null)));
        }
Пример #5
0
        public List <Category> GetCategories()
        {
            ImeshmaEntities _db = new ImeshmaEntities();

            return(_db.Categories.ToList());
        }