Example #1
0
        public virtual ProductGenre UpdateProductGenre(ProductGenre entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            ProductGenre other = GetProductGenre(entity.ProductId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update ProductGenre set  [GenreID]=@GenreID
							, [DisplayOrder]=@DisplayOrder
							, [CreatedOn]=@CreatedOn 
							 where ProductID=@ProductID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@ProductID", entity.ProductId)
                , new SqlParameter("@GenreID", entity.GenreId)
                , new SqlParameter("@DisplayOrder", entity.DisplayOrder)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetProductGenre(entity.ProductId));
        }
Example #2
0
        public virtual ProductGenre InsertProductGenre(ProductGenre entity)
        {
            ProductGenre other = new ProductGenre();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into ProductGenre ( [ProductID]
				,[GenreID]
				,[DisplayOrder]
				,[CreatedOn] )
				Values
				( @ProductID
				, @GenreID
				, @DisplayOrder
				, @CreatedOn );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@ProductID", entity.ProductId)
                    , new SqlParameter("@GenreID", entity.GenreId)
                    , new SqlParameter("@DisplayOrder", entity.DisplayOrder)
                    , new SqlParameter("@CreatedOn", entity.CreatedOn)
                };
                var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray);
                if (identity == DBNull.Value)
                {
                    throw new DataException("Identity column was null as a result of the insert operation.");
                }
                return(GetProductGenre(Convert.ToInt32(identity)));
            }
            return(entity);
        }
Example #3
0
        private string GenerateCode(ProductGenre product)
        {
            string productCategoryCode = db.ProductCategories.Find(product.ProductCategoryId).Code;
            string profileCode         = db.PipeProfiles.Find(product.PipeProfileId).Code;
            string diameterCode        = db.PipeDiameters.Find(product.PipeDiameterId).Code;

            return(productCategoryCode + profileCode + diameterCode);
        }
Example #4
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            ProductGenre productGenre = db.ProductGenres.Find(id);

            db.ProductGenres.Remove(productGenre);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #5
0
 public ActionResult Edit(ProductGenre productGenre)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productGenre).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PipeDiameterId    = new SelectList(db.PipeDiameters, "Id", "Size", productGenre.PipeDiameterId);
     ViewBag.PipeProfileId     = new SelectList(db.PipeProfiles, "Id", "Name", productGenre.PipeProfileId);
     ViewBag.ProductCategoryId = new SelectList(db.ProductCategories, "Id", "Name", productGenre.ProductCategoryId);
     return(View(productGenre));
 }
Example #6
0
        public virtual ProductGenre ProductGenreFromDataRow(DataRow dr)
        {
            if (dr == null)
            {
                return(null);
            }
            ProductGenre entity = new ProductGenre();

            entity.ProductId    = (System.Int32)dr["ProductID"];
            entity.GenreId      = (System.Int32)dr["GenreID"];
            entity.DisplayOrder = (System.Int32)dr["DisplayOrder"];
            entity.CreatedOn    = (System.DateTime)dr["CreatedOn"];
            return(entity);
        }
Example #7
0
        // GET: Commerce/ProductGenres/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductGenre productGenre = db.ProductGenres.Find(id);

            if (productGenre == null)
            {
                return(HttpNotFound());
            }
            return(View(productGenre));
        }
Example #8
0
        public ActionResult Create(ProductGenre productGenre)
        {
            if (ModelState.IsValid)
            {
                productGenre.Id   = Guid.NewGuid();
                productGenre.Code = GenerateCode(productGenre);
                db.ProductGenres.Add(productGenre);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PipeDiameterId    = new SelectList(db.PipeDiameters, "Id", "Size", productGenre.PipeDiameterId);
            ViewBag.PipeProfileId     = new SelectList(db.PipeProfiles, "Id", "Name", productGenre.PipeProfileId);
            ViewBag.ProductCategoryId = new SelectList(db.ProductCategories, "Id", "Name", productGenre.ProductCategoryId);
            return(View(productGenre));
        }
Example #9
0
        // GET: Commerce/ProductGenres/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductGenre productGenre = db.ProductGenres.Find(id);

            if (productGenre == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PipeDiameterId    = new SelectList(db.PipeDiameters, "Id", "Size", productGenre.PipeDiameterId);
            ViewBag.PipeProfileId     = new SelectList(db.PipeProfiles, "Id", "Name", productGenre.PipeProfileId);
            ViewBag.ProductCategoryId = new SelectList(db.ProductCategories, "Id", "Name", productGenre.ProductCategoryId);
            return(View(productGenre));
        }
 public ProductGenre InsertProductGenre(ProductGenre entity)
 {
     return(_iProductGenreRepository.InsertProductGenre(entity));
 }
 public ProductGenre UpdateProductGenre(ProductGenre entity)
 {
     return(_iProductGenreRepository.UpdateProductGenre(entity));
 }
Example #12
0
 public virtual ProductGenre DeleteProductGenre(ProductGenre entity)
 {
     this.DeleteProductGenre(entity.ProductId);
     return(entity);
 }