예제 #1
0
        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);
 }
예제 #3
0
        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;
        }
예제 #4
0
        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;
        }
예제 #5
0
        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);
        }