コード例 #1
0
        public async Task <ActionResult> AddOrEditCompany(CompanyModel comp)
        {
            comp.CreatedBy = CurrentUser.UserId;
            if (comp.CompanyLogo != null && comp.CompanyPath != null)
            {
                if (System.IO.File.Exists(Server.MapPath(_path + "Logo/" + comp.CompanyLogo)))
                {
                    System.IO.File.Delete(Server.MapPath(_path + "Logo/" + comp.CompanyLogo));
                }
            }
            if (comp.CompanyPath != null)
            {
                comp.CompanyLogo = SaveImageFile(comp.CompanyPath, "Logo");
            }
            var response = await _compRepo.AddUpdateDeleteCompany(comp);

            comp.ActiveTab       = "tab-2";
            TempData["response"] = response;
            comp.CompanyId       = new Guid(response.result);
            comp.CompanyTypeList = new SelectList(await CommonModel.GetLookup("Company Type"), "Value", "Text");
            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.BankDetail.BankList     = new SelectList(await CommonModel.GetLookup("Bank"), "Value", "Text");
            comp.Contact.AddressTypelist = new SelectList(await CommonModel.GetLookup("Address"), "value", "Text");
            comp.Contact.CountryList     = new SelectList(_dropdown.BindCountry(), "Value", "Text");
            comp.Contact.StateList       = new SelectList(Enumerable.Empty <SelectList>());
            comp.Contact.CityList        = new SelectList(Enumerable.Empty <SelectList>());
            comp.Contact.LocationList    = new SelectList(_dropdown.BindLocation(), "Value", "Text");
            comp.Agreement.ServiceList   = await CommonModel.GetServiceType(new FilterModel { CompId = comp.CompanyId });

            comp.Agreement.DeliveryServiceList = await CommonModel.GetDeliveryServiceType(new FilterModel { CompId = comp.CompanyId });

            if (comp.Action == 'I')
            {
                comp.ActiveTab           = "tab-2";
                comp.Organization.RefKey = comp.CompanyId;
                TempData["Comp"]         = comp;
                TempData.Keep("Comp");
                return(View("Create", comp));
            }
            else
            {
                comp = await GetCompany(comp.CompanyId);

                comp.ActiveTab = "tab-2";
                return(View("Edit", comp));
            }
        }