public async Task <ActionResult> EditSacCode(int sacCodeId)
        {
            using (var con = new SqlConnection(_connectionString))
            {
                var result = con.Query <SacCodesModel>("Select * from MstSacCodes Where SacCodesId=@SacCodesId", new { @SacCodesId = sacCodeId },
                                                       commandType: CommandType.Text).FirstOrDefault();
                result.CountryList = new SelectList(dropdown.BindCountry(), "Value", "Text");
                result.StateList   = new SelectList(dropdown.BindState(result.CountryId), "Value", "Text");
                result.GstList     = new SelectList(dropdown.BindGst(null), "Value", "Text");
                var applicationTaxTypeList = await CommonModel.GetApplicationTaxType();

                result.AplicationTaxTypeList = new SelectList(applicationTaxTypeList, "Value", "Text");
                result.InitialHSNCode        = result.Gst_HSN_Code;
                if (result != null)
                {
                    if (result.Product_Sale_Range != null)
                    {
                        if (result.Product_Sale_Range.Contains("-"))
                        {
                            string   productSale = result.Product_Sale_Range;
                            string[] parts       = productSale.ToString().Split('-');
                            result.Product_Sale_From = parts[0];
                            result.Product_Sale_TO   = parts[1];
                        }
                        else
                        {
                            result.Product_Sale_From = result.Product_Sale_Range;
                        }
                    }
                }
                return(View(result));
            }
        }
Beispiel #2
0
        public async Task <ActionResult> Edit(int?courierId)
        {
            using (var con = new SqlConnection(_connectionString))
            {
                var folder = "/UploadedImages/Courier/";
                var result = con.Query <ManageCourierModel>("SELECT * from Courier_Master WHERE CourierId=@CourierId", new { CourierId = courierId },
                                                            commandType: CommandType.Text).FirstOrDefault();
                result.UploadedCourierFileUrl = folder + "Logo/" + result.UploadedCourierFile;
                result.UploadedGSTFileUrl     = folder + "Gst/" + result.UploadedGSTFile;
                result.UserPANCardFileUrl     = folder + "PanCards/" + result.UserPANCardFile;
                result.VoterIDFileUrl         = folder + "VoterCards/" + result.VoterIDFile;
                result.AadhaarCardFileUrl     = folder + "AdharCards/" + result.AadhaarCardFile;
                result.AgreementScanFileUrl   = folder + "ScanAgreement/" + result.AgreementScanFile;
                result.CancelledChequeFileUrl = folder + "CancelledCheques/" + result.CancelledChequeFile;
                if (result != null)
                {
                    result.Country       = result.CountryId;
                    result.StateDropdown = result.StateId;
                    result.CityDropdown  = result.CityId;

                    result.PinCodeDropdown       = result.Pincode;
                    result.SC_CountryDropdown    = result.SC_Country;
                    result.PersonCountryDropdown = result.PersonCountry;
                    result.PersonCityDropdown    = result.PersonCity;
                    result.PersonStateDropdown   = result.PersonState;
                    result.SC_PincodeDropdown    = result.SC_Pincode;
                    string volume = result.Volume.ToString();
                    result.CountryList                   = new SelectList(dropdown.BindCountry(), "Value", "Text");
                    result.StateList                     = new SelectList(dropdown.BindState(), "Value", "Text");
                    result.CityList                      = new SelectList(dropdown.BindLocation(), "Value", "Text");
                    result.PincodeList                   = new SelectList(dropdown.BindPincodeListByCountry(Convert.ToInt32(result.SC_Country)), "Value", "Text");
                    result.ApplicableTaxTypeList         = new SelectList(await CommonModel.GetApplicationTaxType(), "Value", "Text");
                    result.PersonAddressTypeList         = new SelectList(CommonModel.GetAddressTypes(), "Value", "Text");
                    result.AWBNumberUsedList             = new SelectList(await CommonModel.GetAWBNumberUsedTypes(), "Value", "Text");
                    result.AgreementSignupList           = new SelectList(await CommonModel.GetAgreementSignup(), "Value", "Text");
                    result.LegalDocumentVerificationList = new SelectList(await CommonModel.GetLegalDocumentVerification(), "Value", "Text");
                    string[] parts = volume.ToString().Split('-');
                    result.Volumn1 = parts[0];
                    result.Volumn2 = parts[1];
                    string   weight = result.WeightRange.ToString();
                    string[] parts1 = weight.ToString().Split('-');
                    result.WeightRange1       = parts[0];
                    result.WeightRange2       = parts[1];
                    result.AgreementEndDate   = Convert.ToDateTime(result.AgreementEndDate).ToString("MM-dd-yyyy");
                    result.AgreementStartDate = Convert.ToDateTime(result.AgreementStartDate).ToString("MM-dd-yyyy");
                    result.ApplicableFromDate = Convert.ToDateTime(result.ApplicableFromDate).ToString("MM-dd-yyyy");
                }

                return(View(result));
            }
        }
Beispiel #3
0
        public async Task <ActionResult> Create()
        {
            DropdownBindController drop         = new DropdownBindController();
            ManageCourierModel     courierModel = new ManageCourierModel
            {
                CountryList                   = new SelectList(dropdown.BindCountry(), "Value", "Text"),
                StateList                     = new SelectList(Enumerable.Empty <SelectListItem>()),
                CityList                      = new SelectList(Enumerable.Empty <SelectListItem>()),
                PincodeList                   = new SelectList(Enumerable.Empty <SelectListItem>()),
                ApplicableTaxTypeList         = new SelectList(await CommonModel.GetApplicationTaxType(), "Value", "Text"),
                PersonAddressTypeList         = new SelectList(CommonModel.GetAddressTypes(), "Value", "Text"),
                AWBNumberUsedList             = new SelectList(await CommonModel.GetAWBNumberUsedTypes(), "Value", "Text"),
                AgreementSignupList           = new SelectList(await CommonModel.GetAgreementSignup(), "Value", "Text"),
                LegalDocumentVerificationList = new SelectList(await CommonModel.GetLegalDocumentVerification(), "Value", "Text")
            };

            return(View(courierModel));
        }
        public async Task <ActionResult> AddorEditOrganization(ClientModel client, OrganizationModel org)
        {
            var cltns = TempData["client"] as ClientModel;

            if (TempData["client"] != null)
            {
                client = cltns;
                client.Organization = org;
            }
            else
            {
                client.Organization = org;
            }

            if (client.Organization.OrgGSTNumberFilePath != null && client.Organization.OrgGSTFileName != null)
            {
                if (System.IO.File.Exists(Server.MapPath(_path + "Gsts/" + client.Organization.OrgGSTFileName)))
                {
                    System.IO.File.Delete(Server.MapPath(_path + "Gsts/" + client.Organization.OrgGSTFileName));
                }
            }
            if (client.Organization.OrgPanNumberFilePath != null && client.Organization.OrgPanFileName != null)
            {
                if (System.IO.File.Exists(Server.MapPath(_path + "PANCards/" + client.Organization.OrgPanFileName)))
                {
                    System.IO.File.Delete(Server.MapPath(_path + "PANCards/" + client.Organization.OrgPanFileName));
                }
            }

            if (client.Organization.OrgGSTNumberFilePath != null)
            {
                client.Organization.OrgGSTFileName = SaveImageFile(client.Organization.OrgGSTNumberFilePath, "Gsts");
            }
            if (client.Organization.OrgPanNumberFilePath != null)
            {
                client.Organization.OrgPanFileName = SaveImageFile(client.Organization.OrgPanNumberFilePath, "PANCards");
            }
            var statutory = await CommonModel.GetStatutoryType();

            client.Organization.StatutoryList = new SelectList(statutory, "Value", "Text");
            var applicationTaxTypeList = await CommonModel.GetApplicationTaxType();

            client.Organization.AplicationTaxTypeList = new SelectList(applicationTaxTypeList, "Value", "Text");
            client.Organization.GstCategoryList       = new SelectList(dropdown.BindGst(null), "Value", "Text");


            client.Activetab = "tab-2";
            client.CreatedBy = CurrentUser.UserId;
            client.CompanyId = CurrentUser.CompanyId;
            var response = await _client.AddUpdateDeleteClient(client);

            _client.Save();
            client.ClientId      = new Guid(response.result);
            TempData["response"] = response;
            client.Activetab     = "tab-3";
            if (client.action == 'I')
            {
                TempData["client"] = client;
                TempData.Keep("client");
                return(View("Create", client));
            }
            else
            {
                var clt = await GetClient(client.ClientId);

                clt.Activetab = "tab-3";
                return(View("Edit", clt));
            }
        }
        public async Task <ActionResult> AddorEditClient(ClientModel client)
        {
            var statutory = await CommonModel.GetStatutoryType();

            var applicationTaxTypeList = await CommonModel.GetApplicationTaxType();

            var cltns = TempData["client"] as ClientModel;

            client.Organization = new OrganizationModel();

            if (TempData["client"] != null)
            {
                client = cltns;
            }
            else
            {
                client.ProcessList = new SelectList(await CommonModel.GetProcesses(CurrentUser.CompanyId), "Value", "Text");
                client.Organization.GstCategoryList       = new SelectList(dropdown.BindGst(null), "Value", "Text");
                client.Organization.StatutoryList         = new SelectList(statutory, "Value", "Text");
                client.Organization.AplicationTaxTypeList = new SelectList(applicationTaxTypeList, "Value", "Text");
                client.Bank.BankList           = new SelectList(await CommonModel.GetLookup("Bank"), "Value", "Text");
                client.Contact.AddressTypelist = new SelectList(await CommonModel.GetLookup("Address"), "value", "Text");

                //client.Contact.CityList = new SelectList(await CommonModel.GetLookup("City"), "Value", "Text");
                client.Contact.LocationList = client.Contact.LocationList = new SelectList(dropdown.BindLocationByPinCode(client.Contact.PinNumber), "Value", "Text");
                if (CurrentUser.UserTypeName.ToLower().Contains("super admin"))
                {
                    client.CompanyList  = new SelectList(await CommonModel.GetCompanies(), "Name", "Text");
                    client.IsSuperAdmin = true;
                }
                client.Service = new ServiceViewModel
                {
                    SupportedCategoryList    = new SelectList(dropdown.BindCategory(CurrentUser.CompanyId), "Value", "Text"),
                    SupportedSubCategoryList = new SelectList(Enumerable.Empty <SelectList>()),
                    ServiceList = new SelectList(await doorserve.CommonModel.GetServiceType(new FilterModel {
                        CompId = CurrentUser.CompanyId
                    }), "Value", "Text"),
                    DeliveryServiceList = new SelectList(await doorserve.CommonModel.GetDeliveryServiceType(new FilterModel {
                        CompId = CurrentUser.CompanyId
                    }), "Value", "Text"),
                    ServiceId      = null,
                    SubCategoryId  = 0,
                    CategoryId     = 0,
                    ServiceTypeId  = 0,
                    DeliveryTypeId = 0,
                    Remarks        = null,
                    IsActive       = false
                };

                client.Activetab = "tab-1";
                client.CreatedBy = CurrentUser.UserId;
                if (!CurrentUser.UserTypeName.ToLower().Contains("super admin"))
                {
                    client.CompanyId = CurrentUser.CompanyId;
                }
            }
            var response = await _client.AddUpdateDeleteClient(client);

            _client.Save();
            client.ClientId       = new Guid(response.result);
            client.Service.RefKey = client.ClientId;
            TempData["response"]  = response;
            client.Activetab      = "tab-2";
            if (client.action == 'I')
            {
                TempData["client"] = client;
                return(View("Create", client));
            }
            else
            {
                var clt = await GetClient(client.ClientId);

                clt.Activetab = "tab-2";
                return(View("Edit", clt));
            }
        }
        private async Task <ClientModel> GetClient(Guid?clientId)
        {
            var Client = await _client.GetClientByClientId(clientId);

            Client.Path = _path;

            if (Client.Organization == null)
            {
                Client.Organization = new OrganizationModel();
            }


            Client.Organization.GstCategoryList = new SelectList(dropdown.BindGst(null), "Value", "Text");
            var statutory = await CommonModel.GetStatutoryType();

            Client.Organization.StatutoryList = new SelectList(statutory, "Value", "Text");
            var applicationTaxTypeList = await CommonModel.GetApplicationTaxType();

            Client.Organization.AplicationTaxTypeList = new SelectList(applicationTaxTypeList, "Value", "Text");

            Client.Bank.BankList           = new SelectList(await CommonModel.GetLookup("Bank"), "Value", "Text");
            Client.Contact.AddressTypelist = new SelectList(await CommonModel.GetLookup("Address"), "value", "Text");
            Client.Contact.CountryList     = new SelectList(dropdown.BindCountry(), "Value", "Text");
            Client.Contact.StateList       = new SelectList(Enumerable.Empty <SelectList>());
            Client.Contact.CityList        = new SelectList(Enumerable.Empty <SelectList>());
            Client.Contact.LocationList    = new SelectList(Enumerable.Empty <SelectList>());
            Client.Service = new ServiceViewModel
            {
                SupportedCategoryList    = new SelectList(dropdown.BindCategory(CurrentUser.CompanyId), "Value", "Text"),
                SupportedSubCategoryList = new SelectList(Enumerable.Empty <SelectList>()),
                ServiceList = new SelectList(await doorserve.CommonModel.GetServiceType(new FilterModel {
                    CompId = CurrentUser.CompanyId
                }), "Value", "Text"),
                DeliveryServiceList = new SelectList(await doorserve.CommonModel.GetDeliveryServiceType(new FilterModel {
                    CompId = CurrentUser.CompanyId
                }), "Value", "Text"),
                RefKey = clientId
            };

            if (CurrentUser.UserTypeName.ToLower().Contains("super admin"))
            {
                Client.CompanyList = new SelectList(await CommonModel.GetCompanies(), "Name", "Text");
                if (Client.CompanyId != null)
                {
                    Client.ProcessList = new SelectList(await CommonModel.GetProcesses(Client.CompanyId), "Value", "Text");
                }
                else
                {
                    Client.ProcessList = new SelectList(Enumerable.Empty <SelectList>());
                }
                Client.IsSuperAdmin = true;
            }
            else
            {
                Client.CompanyList = new SelectList(Enumerable.Empty <SelectList>());
                if (clientId == null)
                {
                    Client.ProcessList = new SelectList(await CommonModel.GetProcesses(CurrentUser.CompanyId), "Value", "Text");
                    Client.CompanyId   = CurrentUser.CompanyId;
                }
                else
                {
                    Client.ProcessList = new SelectList(await CommonModel.GetProcesses(Client.CompanyId), "Value", "Text");
                }
            }
            if (clientId != null)
            {
                Client.action = 'U';
            }
            else
            {
                Client.action = 'I';
            }


            return(Client);
        }
Beispiel #7
0
        public async Task <ActionResult> Create(ManageCourierModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var con = new SqlConnection(_connectionString))
                    {
                        string UploadedCourierFile = SaveImageFile(model.UploadedCourierFilePath, "Courier/Logo");
                        string UploadedGSTFile     = SaveImageFile(model.UploadedGSTFilePath, "Courier/Gst");
                        string PANCardFile         = SaveImageFile(model.PANCardFilePath, "Courier/PanCards");
                        string UserPANCardFile     = SaveImageFile(model.UserPANCardFilePath, "Courier/Pancards");
                        string VoterIDFile         = SaveImageFile(model.VoterIDFilePath, "Courier/VoterCards");
                        string AadhaarCardFile     = SaveImageFile(model.AadhaarCardFilePath, "Courier/AdharCards");
                        string AgreementScanFile   = SaveImageFile(model.AgreementScanFilePath, "Courier/ScanAgreement");
                        string CancelledChequeFile = SaveImageFile(model.CancelledChequeFilePath, "Courier/CancelledCheques");
                        var    result = con.Query <int>("Add_Modify_Delete_Courier",
                                                        new
                        {
                            //Settings
                            model.CourierId,
                            model.CourierName,
                            model.CourierCode,
                            model.CourierBrandName,
                            model.Priority,
                            model.CourierTAT,
                            model.AWBNumber,
                            //CountryId = model.Country,
                            //StateId = model.StateDropdown,
                            // CityId = model.CityDropdown,
                            model.CountryId,
                            model.StateId,
                            model.CityId,

                            UploadedCourierFile,
                            model.IsReverse,
                            model.IsAllowPreference,
                            //Organisation
                            model.CourierCompanyName,
                            model.OrganizationCode,
                            model.StatutoryType,
                            model.ApplicableTaxType,
                            model.GSTNumber,
                            UploadedGSTFile,
                            model.PANCardNumber,
                            PANCardFile,
                            model.BikeMakeandModel,
                            model.BikeNumber,
                            //Address and Contact Person
                            model.PersonAddresstype,
                            PersonCountry = model.PersonCountryDropdown,
                            PersonState   = model.PersonStateDropdown,
                            PersonCity    = model.PersonCityDropdown,
                            model.FullAddress,
                            model.Locality,
                            model.NearByLocation,
                            model.Pincode,
                            model.FirstName,
                            model.LastName,
                            model.MobileNumber,
                            model.EmailAddress,
                            model.UserPANCard,
                            UserPANCardFile,
                            model.VoterIDCardNo,
                            VoterIDFile,
                            model.AadhaarCardNo,
                            AadhaarCardFile,
                            model.IsUser,
                            //Service Charge
                            SC_Country = model.SC_CountryDropdown,
                            SC_Pincode = model.SC_PincodeDropdown,
                            model.Currency,
                            model.ServiceChargeType,
                            model.ValueRange,
                            WeightRange = model.WeightRange1 + "-" + model.WeightRange2,
                            Volume      = model.Volumn1 + "-" + model.Volumn2,
                            model.ServiceCharge,
                            model.ApplicableFromDate,
                            model.ItemType,
                            //Agreement
                            model.LegalDocumentVerificationStatus,
                            model.AgreementSignupStatus,
                            model.AgreementStartDate,
                            model.AgreementEndDate,
                            model.AgreementNumber,
                            AgreementScanFile,
                            //Bank Details
                            model.BankName,
                            model.BankAccountNumber,
                            model.CompanyNameatBank,
                            model.IFSCCode,
                            model.BankBranch,
                            CancelledChequeFile,
                            model.PaymentCycle,
                            //Registration
                            model.LuluandSky_Status,
                            model.Comments,
                            model.IsActive,
                            User = CurrentUser.UserId,
                            CurrentUser.CompanyId,
                            Action = "I",
                        }, commandType: CommandType.StoredProcedure).FirstOrDefault();
                        var response = new ResponseModel();
                        if (result == 1)
                        {
                            response.IsSuccess   = true;
                            response.Response    = "New Courier Successfully Added ";
                            TempData["response"] = response;
                        }

                        else
                        {
                            response.IsSuccess   = true;
                            response.Response    = "Courier Already Exist ";
                            TempData["response"] = response;
                        }
                    }
                    //return View(model);
                    return(RedirectToAction("ManageCourier"));
                }
                else
                {
                    model.CountryList                   = new SelectList(dropdown.BindCountry(), "Value", "Text");
                    model.StateList                     = new SelectList(Enumerable.Empty <SelectListItem>());
                    model.CityList                      = new SelectList(Enumerable.Empty <SelectListItem>());
                    model.PincodeList                   = new SelectList(Enumerable.Empty <SelectListItem>());
                    model.ApplicableTaxTypeList         = new SelectList(await CommonModel.GetApplicationTaxType(), "Value", "Text");
                    model.PersonAddressTypeList         = new SelectList(CommonModel.GetAddressTypes(), "Value", "Text");
                    model.AWBNumberUsedList             = new SelectList(await CommonModel.GetAWBNumberUsedTypes(), "Value", "Text");
                    model.AgreementSignupList           = new SelectList(await CommonModel.GetAgreementSignup(), "Value", "Text");
                    model.LegalDocumentVerificationList = new SelectList(await CommonModel.GetLegalDocumentVerification(), "Value", "Text");
                    return(View(model));
                }
            }
            catch (Exception e)
            {
                model.CountryList                   = new SelectList(dropdown.BindCountry(), "Value", "Text");
                model.StateList                     = new SelectList(Enumerable.Empty <SelectListItem>());
                model.CityList                      = new SelectList(Enumerable.Empty <SelectListItem>());
                model.PincodeList                   = new SelectList(Enumerable.Empty <SelectListItem>());
                model.ApplicableTaxTypeList         = new SelectList(await CommonModel.GetApplicationTaxType(), "Value", "Text");
                model.PersonAddressTypeList         = new SelectList(CommonModel.GetAddressTypes(), "Value", "Text");
                model.AWBNumberUsedList             = new SelectList(await CommonModel.GetAWBNumberUsedTypes(), "Value", "Text");
                model.AgreementSignupList           = new SelectList(await CommonModel.GetAgreementSignup(), "Value", "Text");
                model.LegalDocumentVerificationList = new SelectList(await CommonModel.GetLegalDocumentVerification(), "Value", "Text");

                return(View(model));
            }
        }
        public async Task <ActionResult> AddorEditOrganization(OrganizationModel org)
        {
            var Center    = new ServiceCenterModel();
            var statutory = await CommonModel.GetStatutoryType();

            Center.Organization.StatutoryList = new SelectList(statutory, "Value", "Text");
            var applicationTaxTypeList = await CommonModel.GetApplicationTaxType();

            if (!ModelState.IsValid)
            {
                if (TempData["center"] != null)
                {
                    var cltns = TempData["center"] as ServiceCenterModel;
                    Center              = cltns;
                    Center.action       = 'I';
                    Center.Activetab    = "tab-2";
                    Center.Organization = org;

                    return(View("Create", Center));
                }
                else
                {
                    var center = await GetCenter(org.RefKey);

                    center.Activetab = "tab-2";
                    Center.Organization.AplicationTaxTypeList = new SelectList(applicationTaxTypeList, "Value", "Text");
                    Center.Organization.GstCategoryList       = new SelectList(dropdown.BindGst(null), "Value", "Text");
                    Center.Organization.StatutoryList         = new SelectList(statutory, "Value", "Text");
                    return(View("Edit", center));
                }
            }
            else
            {
                if (TempData["center"] != null)
                {
                    var cltns = TempData["center"] as ServiceCenterModel;
                    Center = cltns;
                    Center.Organization = org;
                }
                else
                {
                    Center.Organization = org;
                }

                if (Center.Organization.OrgGSTNumberFilePath != null && Center.Organization.OrgGSTFileName != null)
                {
                    if (System.IO.File.Exists(Server.MapPath(_path + "Gsts/" + Center.Organization.OrgGSTFileName)))
                    {
                        System.IO.File.Delete(Server.MapPath(_path + _path + "Gsts/" + Center.Organization.OrgGSTFileName));
                    }
                }
                if (Center.Organization.OrgPanNumberFilePath != null && Center.Organization.OrgPanFileName != null)
                {
                    if (System.IO.File.Exists(Server.MapPath(_path + "PANCards/" + Center.Organization.OrgPanFileName)))
                    {
                        System.IO.File.Delete(Server.MapPath(_path + "PANCards/" + Center.Organization.OrgPanFileName));
                    }
                }
                if (Center.Organization.OrgGSTNumberFilePath != null)
                {
                    Center.Organization.OrgGSTFileName = SaveImageFile(Center.Organization.OrgGSTNumberFilePath, "Gsts");
                }
                if (Center.Organization.OrgPanNumberFilePath != null)
                {
                    Center.Organization.OrgPanFileName = SaveImageFile(Center.Organization.OrgPanNumberFilePath, "PANCards");
                }

                Center.Activetab = "tab-2";
                Center.CreatedBy = CurrentUser.UserId;
                var response = await _Center.AddUpdateDeleteCenter(Center);

                _Center.Save();
                Center.CenterId = new Guid(response.result);
                Center.Organization.AplicationTaxTypeList = new SelectList(applicationTaxTypeList, "Value", "Text");
                Center.Organization.GstCategoryList       = new SelectList(dropdown.BindGst(null), "Value", "Text");
                Center.Organization.StatutoryList         = new SelectList(statutory, "Value", "Text");
                TempData["response"] = response;
                if (Center.action == 'I')
                {
                    Center.Activetab   = "tab-3";
                    TempData["center"] = Center;
                    return(View("Create", Center));
                }
                else
                {
                    var center = await GetCenter(org.RefKey);

                    center.Activetab = "tab-3";
                    return(View("Edit", center));
                }
            }
        }
        public async Task <ActionResult> AddorEditServiceCenter(ServiceCenterModel Center)
        {
            var statutory = await CommonModel.GetStatutoryType();

            var applicationTaxTypeList = await CommonModel.GetApplicationTaxType();

            var cltns = TempData["center"] as ServiceCenterModel;

            Center.Organization = new OrganizationModel();
            Center.Organization.GstCategoryList       = new SelectList(dropdown.BindGst(null), "Value", "Text");
            Center.Organization.StatutoryList         = new SelectList(statutory, "Value", "Text");
            Center.Organization.AplicationTaxTypeList = new SelectList(applicationTaxTypeList, "Value", "Text");
            Center.Bank.BankList           = new SelectList(await CommonModel.GetLookup("Bank"), "Value", "Text");
            Center.Contact.AddressTypelist = new SelectList(await CommonModel.GetLookup("Address"), "value", "Text");
            Center.Contact.CountryList     = new SelectList(dropdown.BindCountry(), "Value", "Text");
            Center.Contact.StateList       = new SelectList(dropdown.BindState(), "Value", "Text");
            Center.Contact.CityList        = new SelectList(await CommonModel.GetLookup("City"), "Value", "Text");
            Center.Contact.LocationList    = new SelectList(dropdown.BindLocation(), "Value", "Text");
            Center.ProviderList            = new SelectList(await CommonModel.GetServiceProviders(CurrentUser.CompanyId), "Name", "Text");
            Center.Service = new ServiceOfferedModel
            {
                SupportedCategoryList    = new SelectList(dropdown.BindCategory(CurrentUser.CompanyId), "Value", "Text"),
                SupportedSubCategoryList = new SelectList(dropdown.BindCountry(), "Value", "Text"),
                ServiceList = new SelectList(await doorserve.CommonModel.GetServiceType(new FilterModel {
                    CompId = CurrentUser.CompanyId
                }), "Value", "Text"),
                DeliveryServiceList = new SelectList(await doorserve.CommonModel.GetDeliveryServiceType(new FilterModel {
                    CompId = CurrentUser.CompanyId
                }), "Value", "Text"),
                LocationList = new SelectList(Enumerable.Empty <SelectList>()),
            };


            if (CurrentUser.UserTypeName.ToLower().Contains("super admin"))
            {
                Center.CompanyList = new SelectList(await CommonModel.GetCompanies(), "Name", "Text");
            }
            else if (CurrentUser.UserTypeName.ToLower().Contains("company"))
            {
                Center.IsCompany    = true;
                Center.ProviderList = new SelectList(await CommonModel.GetServiceProviders(CurrentUser.CompanyId), "Name", "Text");
                Center.CompanyId    = CurrentUser.CompanyId;
            }



            if (TempData["center"] != null)
            {
                Center = cltns;
            }


            // if (!SessionModel.UserTypeName.ToLower().Contains("super admin"))
            //Center.CompanyId = SessionModel.CompanyId;
            Center.Activetab = "tab-1";
            Center.CreatedBy = CurrentUser.UserId;
            var response = await _Center.AddUpdateDeleteCenter(Center);

            _Center.Save();
            Center.CenterId       = new Guid(response.result);
            Center.Service.RefKey = Center.CenterId;

            TempData["response"] = response;


            if (Center.action == 'I')
            {
                Center.Activetab   = "tab-2";
                TempData["center"] = Center;
                TempData.Keep("center");
                return(View("Create", Center));
            }
            else
            {
                var center = await GetCenter(Center.CenterId);

                center.Activetab = "tab-2";
                return(View("Edit", center));
            }
        }
        private async Task <ServiceCenterModel> GetCenter(Guid?centerId)
        {
            var Center = await _Center.GetCenterById(centerId);

            Center.Path = _path;

            if (CurrentUser.UserRole.ToLower().Contains("provider"))
            {
                var providerId = CurrentUser.RefKey;
                var provider   = await _Provider.GetProviderById(providerId);

                Center.IsProvider = true;
            }

            else if (CurrentUser.UserRole.ToLower().Contains("company"))
            {
                Center.IsCompany    = true;
                Center.ProviderList = new SelectList(await CommonModel.GetServiceProviders(CurrentUser.CompanyId), "Name", "Text");
            }
            else
            {
                Center.IsProvider  = false;
                Center.IsCompany   = false;
                Center.CompanyList = new SelectList(await CommonModel.GetCompanies(), "Name", "Text");
                if (Center.CenterId != null)
                {
                    Center.ProviderList = new SelectList(await CommonModel.GetServiceProviders(Center.CompanyId), "Name", "Text");
                }
                else
                {
                    Center.ProviderList = new SelectList(Enumerable.Empty <SelectList>());
                }
            }

            if (Center.Organization == null)
            {
                Center.Organization = new OrganizationModel();
            }
            Center.SupportedCategoryList        = new SelectList(dropdown.BindCategory(CurrentUser.CompanyId), "Value", "Text");
            Center.Organization.GstCategoryList = new SelectList(dropdown.BindGst(null), "Value", "Text");
            var statutory = await CommonModel.GetStatutoryType();

            Center.Organization.StatutoryList = new SelectList(statutory, "Value", "Text");
            var applicationTaxTypeList = await CommonModel.GetApplicationTaxType();

            Center.Organization.AplicationTaxTypeList = new SelectList(applicationTaxTypeList, "Value", "Text");
            Center.ServiceList = await doorserve.CommonModel.GetServiceType(new FilterModel { CompId = CurrentUser.CompanyId, RefKey = Center.CenterId });

            Center.DeliveryServiceList = await doorserve.CommonModel.GetDeliveryServiceType(new FilterModel { CompId = CurrentUser.CompanyId, RefKey = Center.CenterId });

            Center.Bank.BankList           = new SelectList(await CommonModel.GetLookup("Bank"), "Value", "Text");
            Center.Contact.AddressTypelist = new SelectList(await CommonModel.GetLookup("Address"), "value", "Text");
            Center.Contact.CountryList     = new SelectList(dropdown.BindCountry(), "Value", "Text");
            Center.Contact.StateList       = new SelectList(Enumerable.Empty <SelectList>());
            Center.Contact.CityList        = new SelectList(Enumerable.Empty <SelectList>());
            Center.Contact.LocationList    = new SelectList(Enumerable.Empty <SelectListItem>());

            if (centerId != null)
            {
                Center.action = 'U';
            }

            else
            {
                Center.action = 'I';
            }
            List <int> List = new List <int>();

            if (!string.IsNullOrEmpty(Center._deviceCategories))
            {
                var _deviceCat = Center._deviceCategories.Split(',');
                for (int i = 0; i < _deviceCat.Length; i++)
                {
                    List.Add(Convert.ToInt16(_deviceCat[i]));
                }
            }
            if (!string.IsNullOrEmpty(Center.ServiceDeliveryTypes))
            {
                var _DeliveryService = Center.ServiceDeliveryTypes.Split(',');
                for (int i = 0; i < _DeliveryService.Length; i++)
                {
                    var item = Center.DeliveryServiceList.Where(x => x.Value == Convert.ToInt32(_DeliveryService[i])).FirstOrDefault();
                    if (item != null)
                    {
                        item.IsChecked = true;
                    }
                }
            }
            if (!string.IsNullOrEmpty(Center.ServiceTypes))
            {
                var _serviceType = Center.ServiceTypes.Split(',');
                for (int i = 0; i < _serviceType.Length; i++)
                {
                    var item = Center.ServiceList.Where(x => x.Value == Convert.ToInt32(_serviceType[i])).FirstOrDefault();
                    if (item != null)
                    {
                        item.IsChecked = true;
                    }
                }
            }
            Center.DeviceCategories = List;
            return(Center);
        }
        private async Task <ServiceProviderModel> GetProvider(Guid?ProviderId)
        {
            var Provider = await _provider.GetProviderById(ProviderId);

            Provider.Path = _path;



            if (Provider.Organization == null)
            {
                Provider.Organization = new OrganizationModel();
            }


            Provider.Organization.GstCategoryList = new SelectList(dropdown.BindGst(null), "Value", "Text");
            var statutory = await CommonModel.GetStatutoryType();

            Provider.Organization.StatutoryList = new SelectList(statutory, "Value", "Text");
            var applicationTaxTypeList = await CommonModel.GetApplicationTaxType();

            Provider.Organization.AplicationTaxTypeList = new SelectList(applicationTaxTypeList, "Value", "Text");
            Provider.Service = new ServiceOfferedModel
            {
                SupportedCategoryList    = new SelectList(dropdown.BindCategory(CurrentUser.CompanyId), "Value", "Text"),
                SupportedSubCategoryList = new SelectList(dropdown.BindCountry(), "Value", "Text"),
                ServiceList = new SelectList(await doorserve.CommonModel.GetServiceType(new FilterModel {
                    CompId = CurrentUser.CompanyId
                }), "Value", "Text"),
                DeliveryServiceList = new SelectList(await doorserve.CommonModel.GetDeliveryServiceType(new FilterModel {
                    CompId = CurrentUser.CompanyId
                }), "Value", "Text"),
                LocationList = new SelectList(Enumerable.Empty <SelectListItem>()),
                RefKey       = ProviderId
            };


            Provider.Bank.BankList = new SelectList(await CommonModel.GetLookup("Bank"), "Value", "Text");

            Provider.Contact.AddressTypelist = new SelectList(await CommonModel.GetLookup("Address"), "value", "Text");
            Provider.Contact.CountryList     = new SelectList(dropdown.BindCountry(), "Value", "Text");
            Provider.Contact.StateList       = new SelectList(Enumerable.Empty <SelectList>());
            Provider.Contact.CityList        = new SelectList(Enumerable.Empty <SelectList>());
            Provider.Contact.LocationList    = new SelectList(Enumerable.Empty <SelectList>());
            if (CurrentUser.UserTypeName.ToLower().Contains("super admin"))
            {
                Provider.CompanyList  = new SelectList(await CommonModel.GetCompanies(), "Name", "Text");
                Provider.IsSuperAdmin = true;
            }
            else
            {
                Provider.CompanyId = CurrentUser.CompanyId;
            }
            if (ProviderId != null)
            {
                Provider.action = 'U';
            }
            else
            {
                Provider.action = 'I';
            }
            return(Provider);
        }
        public async Task <ActionResult> AddorEditOrganization(ServiceProviderModel provider, OrganizationModel org)
        {
            var cltns = TempData["provider"] as ServiceProviderModel;

            if (TempData["provider"] != null)
            {
                provider = cltns;
                provider.Organization = org;
            }
            else
            {
                provider.Organization = org;
            }

            if (provider.Organization.OrgGSTNumberFilePath != null && provider.Organization.OrgGSTFileName != null)
            {
                if (System.IO.File.Exists(Server.MapPath("~/UploadedImages/Providers/Gsts/" + provider.Organization.OrgGSTFileName)))
                {
                    System.IO.File.Delete(Server.MapPath("~/UploadedImages/Providers/Gsts/" + provider.Organization.OrgGSTFileName));
                }
            }
            if (provider.Organization.OrgPanNumberFilePath != null && provider.Organization.OrgPanFileName != null)
            {
                if (System.IO.File.Exists(Server.MapPath("~/UploadedImages/Providers/PANCards/" + provider.Organization.OrgPanFileName)))
                {
                    System.IO.File.Delete(Server.MapPath("~/UploadedImages/Providers/PANCards/" + provider.Organization.OrgPanFileName));
                }
            }
            if (provider.Organization.OrgGSTNumberFilePath != null)
            {
                provider.Organization.OrgGSTFileName = SaveImageFile(provider.Organization.OrgGSTNumberFilePath, "Gsts");
            }
            if (provider.Organization.OrgPanNumberFilePath != null)
            {
                provider.Organization.OrgPanFileName = SaveImageFile(provider.Organization.OrgPanNumberFilePath, "PANCards");
            }
            var statutory = await CommonModel.GetStatutoryType();

            provider.Organization.StatutoryList = new SelectList(statutory, "Value", "Text");
            var applicationTaxTypeList = await CommonModel.GetApplicationTaxType();

            provider.Organization.AplicationTaxTypeList = new SelectList(applicationTaxTypeList, "Value", "Text");
            provider.Organization.GstCategoryList       = new SelectList(dropdown.BindGst(null), "Value", "Text");
            try
            {
                provider.Activetab = "tab-2";
                provider.CreatedBy = CurrentUser.UserId;
                var response = await _provider.AddUpdateDeleteProvider(provider);

                _provider.Save();
                provider.ProviderId  = new Guid(response.result);
                TempData["response"] = response;
                TempData.Keep("response");
                if (provider.action == 'I')
                {
                    provider.Activetab   = "tab-3";
                    TempData["provider"] = provider;
                    TempData.Keep("provider");
                    return(View("Create", provider));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                if (provider.action == 'I')
                {
                    return(View("Create", provider));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
        }