public async Task UpdateProduct(CreateUpdateProductInput input) {//weiter mit p. 291 //get inspired by //https://github.com/aspnetboilerplate/sample-blog-module/blob/master/src/Abp.Samples.Blog.Application/Application/Services/CrudAppService.cs var entity = await _productRepository.GetAsync(input.Id); input.MapTo(entity);//works since [AutoMap(typeof(Product))] maps two classes in both direction // await _productRepository.UpdateAsync(entity); dont need! calls automatically //We even do not call Update method of the repository. //Because an application service method is a 'unit of work' scope as default. //ABP automatically saves all changes when a 'unit of work' scope ends (without any exception). }
public async Task CreateProduct(CreateUpdateProductInput input) { var product2 = input.MapTo <Product>(); /* var product = new Product * { * Name = input.Name, * Description = input.Description, * Category = input.Category, * Price = input.Price * };*/ //Saving entity with standard Insert method of repositories. await _productRepository.InsertAsync(product2); }