Пример #1
0
        public DataResponse <int> DoBasicImport(Dto.Customer[] customers)
        {
            var resp = new DataResponse <int>();

            var userId = customers.First().UserId;

            var validateResp = ValidateBasic(customers, userId);

            if (validateResp.Type != ResponseType.Success)
            {
                resp.Type      = validateResp.Type;
                resp.ErrorCode = validateResp.ErrorCode;
                return(resp);
            }

            _logger.LogInformation($"Basic data import validation passed for user {userId}");

            using (var tx = _uow.BeginTransaction())
            {
                //add customers including transactions
                _customerBusiness.AddRange(customers);

                tx.Commit();
            }

            _logger.LogInformation($"{customers.Length} customers are imported for user {userId}");

            resp.Data = customers.Length;

            return(resp);
        }
Пример #2
0
        private void CreateDatabaseCustomers(Guid userId)
        {
            var customers = new List <Customer>();

            for (int i = 0; i < 100; i++)
            {
                var    title = "Customer " + i;
                Random rand  = new Random();

                customers.Add(new Customer
                {
                    Id     = 1000 + i,
                    UserId = userId,
                    Title  = title,
                    AuthorizedPersonName = title
                });
            }

            _customerBusiness.AddRange(customers.ToArray());
        }
Пример #3
0
        public Response CreateDemoUserDefaultEntries(Guid userId, string lang)
        {
            var parameters = GetParameters(userId, lang);

            using (var tx = _uow.BeginTransaction())
            {
                //add parameters
                _parameterBusiness.AddRange(parameters);

                var customers = GetCustomers(userId, parameters, lang);

                SetCustomerRemainingBalances(customers);

                //add customers
                _customerBusiness.AddRange(customers);

                tx.Commit();
            }

            return(new Response
            {
                Type = ResponseType.Success
            });
        }