Beispiel #1
0
        public async Task UpdateCreditCardCompanyUnit(UpdateCreditCardCompanyUnitInput input)
        {
            var bankAccountUnit = await _bankAccountUnitRepository.GetAsync(input.BankAccountId);

            Mapper.Map(input, bankAccountUnit);
            await _bankAccountUnitManager.UpdateAsync(bankAccountUnit);

            #region Address Insertion
            if (!ReferenceEquals(input.Addresses, null))
            {
                foreach (var address in input.Addresses)
                {
                    if (address.AddressId != 0)
                        await _addressAppService.UpdateAddressUnit(address);
                    else
                    {
                        if (!string.IsNullOrEmpty(address.Line1) || !string.IsNullOrEmpty(address.Line2) ||
                         !string.IsNullOrEmpty(address.Line4) || !string.IsNullOrEmpty(address.Line4) ||
                         !string.IsNullOrEmpty(address.State) || !string.IsNullOrEmpty(address.Country) ||
                         !string.IsNullOrEmpty(address.Email) || !string.IsNullOrEmpty(address.Phone1) ||
                         !string.IsNullOrEmpty(address.Website))
                        {
                            address.TypeofObjectId = TypeofObject.BankAccountUnit;
                            address.ObjectId = input.BankAccountId;
                            //AutoMapper.Mapper.CreateMap<UpdateAddressUnitInput, CreateAddressUnitInput>();
                            await
                                _addressAppService.CreateAddressUnit(
                                    AutoMapper.Mapper.Map<UpdateAddressUnitInput, CreateAddressUnitInput>(address));
                        }
                    }
                    await CurrentUnitOfWork.SaveChangesAsync();

                }
            }
            #endregion
        }
Beispiel #2
0
        public async Task <CompanyImageOutputDto> UpdateCompanyUnit(TenantExtendedUnitInput input)
        {
            int tenantid = AbpSession.GetTenantId();

            byte[] byteArray = null;
            //using (_unitOfWorkManager.Current.SetTenantId(null))
            //{
            //    var tenant = await TenantManager.GetByIdAsync(tenantid);
            //    tenant.Name = input.TenantName;
            //    CheckErrors(await TenantManager.UpdateAsync(tenant));
            //}


            CompanyImageOutputDto companyLogo = new CompanyImageOutputDto();

            using (_unitOfWorkManager.Current.SetTenantId(tenantid))
            {
                if (input.TenantExtendedId > 0)
                {
                    if (!ReferenceEquals(input.ComapanyLogo, null))
                    {
                        byteArray = await UpdateCompanyLogo(input);
                    }
                    var tenant = await _tenantExtendedUnitRepository.GetAsync(input.TenantExtendedId);

                    Mapper.Map(input, tenant);

                    await _tenantExtendedManager.UpdateAsync(tenant);

                    companyLogo.TenantExtendedId = tenant.Id;
                    // update address Information
                    if (!ReferenceEquals(input.Address, null))
                    {
                        if (input.Address.AddressId != 0)
                        {
                            input.Address.TypeofObjectId = TypeofObject.OrganizationUnit;
                            await _addressAppService.UpdateAddressUnit(input.Address);

                            companyLogo.AddressId = input.Address.AddressId;
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(input.Address.Line1) || !string.IsNullOrEmpty(input.Address.Line2) ||
                                !string.IsNullOrEmpty(input.Address.Line3) || !string.IsNullOrEmpty(input.Address.Line4) ||
                                !string.IsNullOrEmpty(input.Address.State) || !string.IsNullOrEmpty(input.Address.Country) ||
                                !string.IsNullOrEmpty(input.Address.Email) || !string.IsNullOrEmpty(input.Address.Phone1) ||
                                !string.IsNullOrEmpty(input.Address.Website))
                            {
                                input.Address.TypeofObjectId = TypeofObject.OrganizationUnit;
                                input.Address.ObjectId       = input.TenantExtendedId;
                                // AutoMapper.Mapper.CreateMap<UpdateAddressUnitInput, CreateAddressUnitInput>();
                                //var config = new MapperConfiguration(cfg => {
                                //    cfg.CreateMap<UpdateAddressUnitInput, CreateAddressUnitInput>();
                                //});

                                var addr = await _addressAppService.CreateAddressUnit(
                                    AutoMapper.Mapper.Map <UpdateAddressUnitInput, CreateAddressUnitInput>(input.Address));

                                companyLogo.AddressId = addr.AddressId;
                            }
                        }
                    }
                }
                else
                {
                    if (!ReferenceEquals(input.ComapanyLogo, null))
                    {
                        byteArray = await UpdateCompanyLogo(input);
                    }
                    var tenantExtended = input.MapTo <TenantExtendedUnit>();
                    int id             = await _tenantExtendedManager.CreateAsync(tenantExtended);

                    companyLogo.TenantExtendedId = id;
                    //address Information
                    if (!ReferenceEquals(input.Address, null))
                    {
                        if (!string.IsNullOrEmpty(input.Address.Line1) || !string.IsNullOrEmpty(input.Address.Line2) ||
                            !string.IsNullOrEmpty(input.Address.Line4) || !string.IsNullOrEmpty(input.Address.Line4) ||
                            !string.IsNullOrEmpty(input.Address.State) || !string.IsNullOrEmpty(input.Address.Country) ||
                            !string.IsNullOrEmpty(input.Address.Email) || !string.IsNullOrEmpty(input.Address.Phone1) ||
                            !string.IsNullOrEmpty(input.Address.ContactNumber))
                        {
                            input.Address.TypeofObjectId = TypeofObject.OrganizationUnit;
                            input.Address.ObjectId       = id;
                            // AutoMapper.Mapper.CreateMap<UpdateAddressUnitInput, CreateAddressUnitInput>();
                            var config = new MapperConfiguration(cfg => {
                                cfg.CreateMap <UpdateAddressUnitInput, CreateAddressUnitInput>();
                            });
                            var addr = await _addressAppService.CreateAddressUnit(
                                AutoMapper.Mapper.Map <UpdateAddressUnitInput, CreateAddressUnitInput>(input.Address));

                            companyLogo.AddressId = addr.AddressId;
                        }
                    }
                }
                await CurrentUnitOfWork.SaveChangesAsync();

                if (byteArray != null)
                {
                    companyLogo.CompanyLogo   = Convert.ToBase64String(byteArray);
                    companyLogo.CompanyLogoId = input.CompanyLogoId;
                }
                return(companyLogo);
            }
        }
Beispiel #3
0
        public async Task <CustomerUnitDto> UpdateCustomerUnit(UpdateCustomerUnitInput input)
        {
            var customerUnit = await _customerUnitRepository.GetAsync(input.CustomerId);

            // update address Information
            if (!ReferenceEquals(input.Addresses, null))
            {
                foreach (var address in input.Addresses)
                {
                    if (address.AddressId != 0)
                    {
                        await _addressAppService.UpdateAddressUnit(address);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(address.Line1) || !string.IsNullOrEmpty(address.Line2) ||
                            !string.IsNullOrEmpty(address.Line4) || !string.IsNullOrEmpty(address.Line4) ||
                            !string.IsNullOrEmpty(address.State) || !string.IsNullOrEmpty(address.Country) ||
                            !string.IsNullOrEmpty(address.Email) || !string.IsNullOrEmpty(address.Phone1) ||
                            !string.IsNullOrEmpty(address.Website))
                        {
                            address.TypeofObjectId = TypeofObject.CustomerUnit;
                            address.ObjectId       = input.CustomerId;
                            //AutoMapper.Mapper.CreateMap<UpdateAddressUnitInput, CreateAddressUnitInput>();
                            //var config = new MapperConfiguration(cfg => {
                            //    cfg.CreateMap<UpdateAddressUnitInput, CreateAddressUnitInput>();
                            //});
                            await
                            _addressAppService.CreateAddressUnit(
                                AutoMapper.Mapper.Map <UpdateAddressUnitInput, CreateAddressUnitInput>(address));
                        }
                    }
                    await CurrentUnitOfWork.SaveChangesAsync();
                }
            }

            #region Setting the values to be updated

            customerUnit.LastName              = input.LastName;
            customerUnit.FirstName             = input.FirstName;
            customerUnit.IsActive              = input.IsActive;
            customerUnit.CreditLimit           = input.CreditLimit;
            customerUnit.CustomerNumber        = input.CustomerNumber;
            customerUnit.CustomerPayTermsId    = input.CustomerPayTermsId;
            customerUnit.CustomerNumber        = input.CustomerNumber;
            customerUnit.SalesRepId            = input.SalesRepId;
            customerUnit.IsApproved            = input.IsApproved;
            customerUnit.OrganizationUnitId    = input.OrganizationUnitId;
            customerUnit.TypeofPaymentMethodId = input.TypeofPaymentMethodId;
            customerUnit.CustomerPayTermsId    = input.CustomerPayTermsId;
            #endregion

            await _customerUnitManager.UpdateAsync(customerUnit);

            await CurrentUnitOfWork.SaveChangesAsync();

            _unitOfWorkManager.Current.Completed += (sender, args) =>
            {
                /*Do Something when the Chart of Customer is Added*/
            };

            var customerUnitDto = customerUnit.MapTo <CustomerUnitDto>();
            customerUnitDto.CustomerId = customerUnit.Id;
            return(customerUnitDto);
        }