/// <summary> /// Inserts product template /// </summary> /// <param name="productTemplate">Product template</param> public virtual void InsertProductTemplate(ProductTemplate productTemplate) { if (productTemplate == null) throw new ArgumentNullException("productTemplate"); _productTemplateRepository.Insert(productTemplate); //event notification _eventPublisher.EntityInserted(productTemplate); }
/// <summary> /// Delete product template /// </summary> /// <param name="productTemplate">Product template</param> public virtual void DeleteProductTemplate(ProductTemplate productTemplate) { if (productTemplate == null) throw new ArgumentNullException("productTemplate"); _productTemplateRepository.Delete(productTemplate); _cacheManager.RemoveByPattern(PRODUCTTEMPLATES_PATTERN_KEY); //event notification _eventPublisher.EntityDeleted(productTemplate); }
public void Can_save_and_load_productTemplate() { var productTemplate = new ProductTemplate { Name = "Name 1", ViewPath = "ViewPath 1", DisplayOrder = 1, }; var fromDb = SaveAndLoadEntity(productTemplate); fromDb.ShouldNotBeNull(); fromDb.Name.ShouldEqual("Name 1"); fromDb.ViewPath.ShouldEqual("ViewPath 1"); fromDb.DisplayOrder.ShouldEqual(1); }
public ActionResult ProductTemplateAdd([Bind(Exclude = "Id")] ProductTemplateModel model, GridCommand command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) return AccessDeniedView(); if (!ModelState.IsValid) { //display the first model error var modelStateErrors = this.ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage); return Content(modelStateErrors.FirstOrDefault()); } var template = new ProductTemplate(); template = model.ToEntity(template); _productTemplateService.InsertProductTemplate(template); return ProductTemplates(command); }
public ActionResult ProductTemplateAdd([Bind(Exclude = "Id")] ProductTemplateModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) return AccessDeniedView(); if (!ModelState.IsValid) { return Json(new DataSourceResult { Errors = ModelState.SerializeErrors() }); } var template = new ProductTemplate(); template = model.ToEntity(template); _productTemplateService.InsertProductTemplate(template); return new NullJsonResult(); }
public static ProductTemplate ToEntity(this ProductTemplateModel model, ProductTemplate destination) { return Mapper.Map(model, destination); }