Exemplo n.º 1
0
        public VendorMain AddMainVendor(VendorMainListDto input)
        {
            VendorMain newVendor = new VendorMain();

            newVendor.SupplierCode = System.Guid.NewGuid();
            newVendor.SupplierName = input.SupplierName;
            newVendor.CountryID    = GetCountryIdByCode();
            return(_vendorMainRepository.Insert(newVendor));
        }
Exemplo n.º 2
0
        public void UpdateMainVendor(VendorMainListDto input)
        {
            try
            {
                VendorMain updateMainVendor = _vendorMainRepository.GetAll().Where(s => s.Id == input.id).First();

                updateMainVendor.SupplierName = input.SupplierName;
                updateMainVendor.SupplierCode = input.SupplierCode;

                _vendorMainRepository.Update(updateMainVendor);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public void VerifyDefaultData(string countrycode)
        {
            int CountryID = _countries.FirstOrDefault(x => x.Code == countrycode).Id;

            string[] defaults    = new string[] { "OTHER", "NONE" };
            string   defaultlogo = "default-profile-picture.png";

            // Verify Bank
            foreach (var data in defaults)
            {
                var bank = _Banks.FirstOrDefault(c => c.BankName == data && c.CountryID == CountryID);
                // If not exist for current country, then add  banknames "OTHER" and "NONE" to tblbanks with countryid and enable
                if (bank == null)
                {
                    var client = new Banks()
                    {
                        BankName  = data,
                        CountryID = CountryID,
                        isActive  = true
                    };
                    _Banks.Insert(client);
                }
                else // Enable Bank if not
                {
                    bank.isActive = true;
                    _Banks.Update(bank);
                }

                // Verify Insurer

                var insurer = _insurer.FirstOrDefault(c => c.InsurerName == data && c.CountryID == CountryID);
                // If not exist for current country, then add  InsurerName "OTHER" and "NONE" to tblinsurerMaster with countryid and enable
                if (insurer == null)
                {
                    var client = new InsurerMaster()
                    {
                        InsurerName = data,
                        CountryID   = CountryID,
                        LogoPicture = defaultlogo,
                        Mask        = data,
                        IsActive    = true
                    };
                    int Id = _insurer.InsertAndGetId(client);

                    var logo = new InsurerPics()
                    {
                        Bytes     = GetBytes(defaultlogo),
                        InsurerID = Id,
                    };
                    _insurerpic.Insert(logo);
                }
                else // Enable Bank if not
                {
                    insurer.IsActive = true;
                    _insurer.Update(insurer);
                }

                // Verify Broker

                var broker = _broker.FirstOrDefault(c => c.BrokerName == data && c.CountryID == CountryID);
                // If not exist for current country, then add  brokerName "OTHER" and "NONE" to tblBrokerMaster with countryid and enable
                if (broker == null)
                {
                    var client = new BrokerMaster()
                    {
                        BrokerName  = data,
                        CountryID   = CountryID,
                        LogoPicture = defaultlogo,
                        Mask        = data,
                        IsActive    = true
                    };
                    int id = _broker.InsertAndGetId(client);


                    var logobroker = new BrokerMasterPics()
                    {
                        Bytes    = GetBytes(defaultlogo),
                        BrokerID = id
                    };
                    _brokerpic.Insert(logobroker);
                }
                else // Enable Bank if not
                {
                    broker.IsActive = true;
                    _broker.Update(broker);
                }
                //Default Vendors
                var vendor = _vendors.FirstOrDefault(c => c.SupplierName == data && c.CountryID == CountryID);
                // If not exist for current country, then add  SupplierName "OTHER" and "NONE" to tblVendorMain with countryid and enable
                if (vendor == null)
                {
                    var client = new VendorMain()
                    {
                        SupplierCode = Guid.NewGuid(),
                        SupplierName = data,
                        CountryID    = CountryID
                    };
                    _vendors.Insert(client);
                }

                //Default Towoperator
                var tow = _tow.FirstOrDefault(c => c.Description == data && c.CountryID == CountryID);
                // If not exist for current country, then add  Description "OTHER" and "NONE" to tblTowOperator with countryid and enable
                if (tow == null)
                {
                    var client = new TowOperator()
                    {
                        Description = data,
                        CountryID   = CountryID,
                        isActive    = true
                    };
                    _tow.Insert(client);
                }
            }
        }