コード例 #1
0
        public async Task <Guid> CreateComplaintCodeAsync(ComplaintCode complaintCodeForm, CancellationToken ct)
        {
            var id = Guid.NewGuid();

            ComplaintCodeEntity entity = Mapper.Map <ComplaintCodeEntity>(complaintCodeForm);

            entity.Id = id;

            var newObj  = _dbContext.ComplaintCodes.Add(entity);
            var created = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Could not create the complaint code");
            }

            return(id);
        }
コード例 #2
0
        public async Task <Guid> CreateDepartmentAsync(Department departmentForm, CancellationToken ct)
        {
            var id = Guid.NewGuid();

            DepartmentEntity entity = Mapper.Map <DepartmentEntity>(departmentForm);

            entity.Id = id;

            var newObj  = _dbContext.Departments.Add(entity);
            var created = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Could not create the department");
            }

            return(id);
        }
コード例 #3
0
        public async Task <Guid> CreatePlantAsync(Plant plantForm, CancellationToken ct)
        {
            var id = Guid.NewGuid();

            PlantEntity entity = Mapper.Map <PlantEntity>(plantForm);

            entity.Id = id;

            var newObj  = _dbContext.Plants.Add(entity);
            var created = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Could not create the requested object");
            }

            return(id);
        }
コード例 #4
0
        public async Task <Guid> CreateCustomerAsync(
            Customer customer, CancellationToken ct)
        {
            var customerId = Guid.NewGuid();

            CustomerEntity entity = Mapper.Map <CustomerEntity>(customer);

            entity.Id = customerId;

            var newCustomer = _dbContext.Customers.Add(entity);
            var created     = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Could not create the customer");
            }

            return(customerId);
        }