コード例 #1
0
        /// <summary>
        /// Gets the customer details by identifier.
        /// </summary>
        /// <returns> CustomerVM </returns>
        public async Task <CustomerVM> GetCustomerDetailsById(int id)
        {
            TblMaster1 master1 = await _context.TblMaster1.Where(x => x.Customer == id).FirstOrDefaultAsync();

            TblMaster2 master2 = await _context.TblMaster2.Where(x => x.Customer == id).FirstOrDefaultAsync();

            TblFainformation fainformation = await _context.TblFainformation.Where(x => x.Customer == id).FirstOrDefaultAsync();

            TblConsultant consultant = await _context.TblConsultant.Where(x => x.Customer == id).FirstOrDefaultAsync();

            CustomerVM customerVM = new CustomerVM()
            {
                Id                  = id,
                Salutation          = master1.Salutation,
                Ta                  = master1.Ta,
                Tb                  = master1.Tb,
                SalutationInLetters = master1.SalutationInLetters,
                FirstName           = master1.FirstName,
                CustomerName        = master1.CustomerName,
                AdditionalAddress   = master1.AdditionalAddress,
                AdditionalAddress2  = master1.AdditionalAddress2,
                AdditionalAddress3  = master1.AdditionalAddress3,
                MatchCode           = master1.MatchCode,
                Street              = master1.Street,
                Country             = master1.Country,
                Zip                 = master1.Zip,
                City                = master1.City,
                BirthDate           = master1.DateOfBirth,
                AddressOrigin       = master1.AddressOrigin,
                CustomerState       = master1.CustomerState,

                CustomerInformation = master2.CustomerInformation,
                CustomerCategory    = master2.CustomerCategory,
                LegalForm           = master2.LegalForm,
                Email         = master2.Email,
                ReferenceText = master2.ReferenceText,
                CustomerType  = master2.CustomerType,
                Vat           = master2.Vat,

                MethodOfGeneralPayment = fainformation.MethodOfGeneralPayment,
                CreditLimit            = fainformation.CreditLimit,
                MethodOfVehiclePayment = fainformation.MethodOfVehiclePayment,
                CreditBlocking         = fainformation.CreditBlocking,
                TermsOfGeneralPayment  = fainformation.TermsOfGeneralPayment,
                OpenBalance            = fainformation.OpenBalance,
                TermsOfVehiclePayment  = fainformation.TermsOfVehiclePayment,
                Solvency       = fainformation.Solvency,
                DebtorNumber   = fainformation.DebtorNumber,
                BankInstitute  = fainformation.BankInstitute,
                BankCode       = fainformation.BankCode,
                AccountNumber  = fainformation.AccountNumber,
                BankCollection = fainformation.BankCollection,

                SalesConsultant      = consultant.SalesConsultant,
                AfterSalesConsultant = consultant.AfterSalesConsultant,
                PartsSalesAssistance = consultant.PartsSalesAssistance,
            };

            return(customerVM);
        }
コード例 #2
0
        /// <summary>
        /// Adds the fa information.
        /// </summary>
        /// <param name="values">The values.</param>
        /// <returns></returns>
        public async Task <bool> AddFAInformation(TblFainformation fainformation)
        {
            await _context.TblFainformation.AddAsync(fainformation);

            await _context.SaveChangesAsync();

            return(true);
        }
コード例 #3
0
 public Task <bool> AddFAInformation(TblFainformation fainformation)
 {
     throw new NotImplementedException();
 }
コード例 #4
0
        /// <summary>
        /// Adds the customer asynchronous to database.
        /// </summary>
        /// <param name="customer">The customer.</param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task <bool> AddCustomerAsync(CustomerVM customer)
        {
            if (customer.Id == 0)
            {
                Random      _random     = new Random();
                TblCustomer customerNew = new TblCustomer()
                {
                    CustomerNumber = _random.Next(0, 1000000).ToString(),
                    LastVisit      = DateTime.Now
                };
                TblCustomer currentCustomer = _customerRepository.AddCustomer(customerNew);
                TblMaster1  master1         = new TblMaster1()
                {
                    Salutation          = customer.Salutation,
                    Ta                  = customer.Ta,
                    Tb                  = customer.Tb,
                    SalutationInLetters = customer.SalutationInLetters,
                    FirstName           = customer.FirstName,
                    AdditionalAddress   = customer.AdditionalAddress,
                    AdditionalAddress2  = customer.AdditionalAddress2,
                    AdditionalAddress3  = customer.AdditionalAddress3,
                    MatchCode           = customer.MatchCode,
                    Street              = customer.Street,
                    Country             = customer.Country,
                    Zip                 = customer.Zip,
                    City                = customer.City,
                    DateOfBirth         = customer.BirthDate,
                    AddressOrigin       = customer.AddressOrigin,
                    CustomerState       = customer.CustomerState,
                    CustomerName        = customer.CustomerName,
                    CustomerNavigation  = currentCustomer
                };
                TblMaster2 master2 = new TblMaster2()
                {
                    CustomerInformation = customer.CustomerInformation,
                    CustomerCategory    = customer.CustomerCategory,
                    LegalForm           = customer.LegalForm,
                    Email              = customer.Email,
                    Vat                = customer.Vat,
                    ReferenceText      = customer.ReferenceText,
                    CustomerNavigation = currentCustomer,
                    CustomerType       = customer.CustomerType
                };
                TblFainformation fainformation = new TblFainformation()
                {
                    MethodOfGeneralPayment = customer.MethodOfGeneralPayment,
                    CreditLimit            = customer.CreditLimit,
                    MethodOfVehiclePayment = customer.MethodOfVehiclePayment,
                    CreditBlocking         = customer.CreditBlocking,
                    TermsOfGeneralPayment  = customer.TermsOfGeneralPayment,
                    OpenBalance            = customer.OpenBalance,
                    TermsOfVehiclePayment  = customer.TermsOfVehiclePayment,
                    Solvency           = customer.Solvency,
                    DebtorNumber       = customer.DebtorNumber,
                    BankInstitute      = customer.BankInstitute,
                    BankCode           = customer.BankCode,
                    AccountNumber      = customer.AccountNumber,
                    BankCollection     = customer.BankCollection,
                    CustomerNavigation = currentCustomer
                };
                TblConsultant consultant = new TblConsultant()
                {
                    SalesConsultant      = customer.SalesConsultant,
                    AfterSalesConsultant = customer.AfterSalesConsultant,
                    PartsSalesAssistance = customer.PartsSalesAssistance,
                    CustomerNavigation   = currentCustomer
                };
                var result1 = await _customerRepository.AddMaster1(master1);

                var result2 = await _customerRepository.AddMaster2(master2);

                var result3 = await _customerRepository.AddFAInformation(fainformation);

                var result4 = await _customerRepository.AddConsultant(consultant);

                return(result1 && result2 && result3 && result4);
            }
            else
            {
                //Edit logic here
                return(false);
            }
        }