Exemplo n.º 1
0
        private async Task <CompanyModel> GetCompany(Guid?CompanyId)
        {
            var comp = await _compRepo.GetCompanyDetailByCompanyId(CompanyId);

            comp.CompanyFile     = _path + "Logo/" + comp.CompanyLogo;
            comp.Action          = 'U';
            comp.Path            = _path;
            comp.CompanyTypeList = new SelectList(await CommonModel.GetLookup("Company Type"), "Value", "Text");
            comp.Organization    = await _OrgRepo.GetOrganizationByRefKey(CompanyId);

            if (comp.Organization == null)
            {
                comp.Organization = new OrganizationModel();
            }
            if (!string.IsNullOrEmpty(comp.Organization.OrgGSTFileName))
            {
                comp.Organization.OrgGSTFileUrl = _path + "Gsts/" + comp.Organization.OrgGSTFileName;
            }
            if (!string.IsNullOrEmpty(comp.Organization.OrgPanFileName))
            {
                comp.Organization.OrgPanFileUrl = _path + "PanCards/" + comp.Organization.OrgPanFileName;
            }

            comp.Organization.GstCategoryList       = new SelectList(await CommonModel.GetGstCategory(), "Value", "Text");
            comp.Organization.AplicationTaxTypeList = new SelectList(await CommonModel.GetLookup("Application Tax Type"), "Value", "Text");
            comp.Organization.StatutoryList         = new SelectList(await CommonModel.GetLookup("Statutory Type"), "Value", "Text");
            comp.Contacts = await _ContactPersonRepo.GetContactPersonsByRefKey(comp.CompanyId);

            comp.Contact.AddressTypelist = new SelectList(await CommonModel.GetLookup("Address"), "value", "Text");
            comp.Contact.LocationList    = new SelectList(Enumerable.Empty <SelectList>());
            comp.BankDetails             = await _BankRepo.GetBanksByRefKey(CompanyId);

            comp.BankDetail.BankList = new SelectList(await CommonModel.GetLookup("Bank"), "Value", "Text");
            comp.Agreement           = await _compRepo.GetAgreement(CompanyId);

            if (comp.Agreement == null)
            {
                comp.Agreement = new AgreementModel();
            }
            comp.Agreement.ServiceList = await CommonModel.GetServiceType(new FilterModel());

            comp.Agreement.DeliveryServiceList = await CommonModel.GetDeliveryServiceType(new FilterModel());

            if (!string.IsNullOrEmpty(comp.Agreement.AgreementFile))
            {
                comp.Agreement.AgreementFileUrl = _path + "Agreements/" + comp.Agreement.AgreementFile;
            }
            if (!string.IsNullOrEmpty(comp.Agreement.CancelledChequeFile))
            {
                comp.Agreement.CancelledChequeFileUrl = _path + "Cheques/" + comp.Agreement.CancelledChequeFile;
            }
            if (!string.IsNullOrEmpty(comp.Agreement.DeliveryTypes))
            {
                var _DeliveryService = comp.Agreement.DeliveryTypes.Split(',');
                for (int i = 0; i < _DeliveryService.Length; i++)
                {
                    var item = comp.Agreement.DeliveryServiceList.Where(x => x.Value == Convert.ToInt32(_DeliveryService[i])).FirstOrDefault();
                    if (item != null)
                    {
                        item.IsChecked = true;
                    }
                }
            }

            if (!string.IsNullOrEmpty(comp.Agreement.ServiceTypes))
            {
                var _serviceType = comp.Agreement.ServiceTypes.Split(',');
                for (int i = 0; i < _serviceType.Length; i++)
                {
                    var item = comp.Agreement.ServiceList.Where(x => x.Value == Convert.ToInt32(_serviceType[i])).FirstOrDefault();
                    if (item != null)
                    {
                        item.IsChecked = true;
                    }
                }
            }

            return(comp);
        }