public void Update(ProductTypeModel model)
        {
            var dbModel = _unitOfWork.ProductTypeRepository.Get(model.Id);
            //MapFromModel(dbModel, model);
            dbModel = Mapper.Map(model, dbModel);

            _unitOfWork.ProductTypeRepository.Edit(dbModel);
        }
 public ActionResult Create(ProductTypeModel model)
 {
     if (this.ModelState.IsValid)
     {
         _productTypeService.Create(model);
         return RedirectToAction("Index");
     }
     return View(model);
 }
        public GridResponseModel<ProductTypeModel> Get(GridRequestModel gridRequestModel, ProductTypeModel searchModel)
        {
            var query = _unitOfWork.ProductTypeRepository.Queryable;

            var dbModel = query.ToPagingResult(gridRequestModel);

            var model = dbModel.Rows.Select(m => Mapper.Map<ProductTypeModel>(m)).ToArray();

            var gridData = new GridResponseModel<ProductTypeModel>(gridRequestModel, dbModel.RowCount, model);

            return gridData;
        }
        public ProductTypeModel[] GetyProductType()
        {
            var model = new ProductTypeModel[]
            {
                new ProductTypeModel()
                {
                    Id = 1,
                    Name = "Type1",
                    Products = new HashSet<ProductModel>()
                    {
                        new ProductModel()
                        {
                            Id = 1,
                            Name = "AB"
                        },
                        new ProductModel()
                        {
                            Id = 3,
                            Name = "CD"
                        }
                    }
                },
                new ProductTypeModel()
                {
                    Id = 2,
                    Name = "Type2",
                    Products = new HashSet<ProductModel>()
                    {
                        new ProductModel()
                        {
                            Id = 2,
                            Name = "BC"
                        }
                    }
                }
            };

            return model;
        }
        public void Create(ProductTypeModel model)
        {
            var dbModel = Mapper.Map<ProductType>(model);

            _unitOfWork.ProductTypeRepository.Create(dbModel);
        }
 public ActionResult AjaxEdit(ProductTypeModel model)
 {
     _productTypeService.Update(model);
     return Json(new { success = true }, JsonRequestBehavior.AllowGet);
 }
        public ActionResult Get(GridRequestModel gridRequestModel, ProductTypeModel searchModel, bool _search)
        {
            var data = _productTypeService.Get(gridRequestModel, _search ? searchModel : null);

            return Json(data, JsonRequestBehavior.AllowGet);
        }