コード例 #1
0
        public async Task <Customer> CreateAsync(CustomerSaveModel customerModel)
        {
            var customer = new Customer();

            customerModel.ApplyToEntity(customer, dataStore, positionService);

            await dataStore.SaveAsync(customer);

            return(customer);
        }
コード例 #2
0
        public Customer Create(CustomerSaveModel customerModel)
        {
            var customer = new Customer();

            customerModel.ApplyToEntity(customer, dataStore, positionService);

            dataStore.Save(customer);

            return(customer);
        }
コード例 #3
0
        public async Task UpdateAsync(long id, CustomerSaveModel customerModel)
        {
            var customer = dataStore.Get <Customer>(id);

            if (customer == null)
            {
                throw new EntityNotFoundException($"Запись типа {typeof(Customer).Name} c идентификатором {id} не существует");
            }

            customerModel.ApplyToEntity(customer, dataStore, positionService);

            await dataStore.SaveChangesAsync();
        }