Esempio n. 1
0
        public async Task <IActionResult> SetSiteSetting(SiteSettingVM input)
        {
            var strList = new List <string> {
                input.Name, input.Suffix
            };

            if (StrIsNull(strList))
            {
                return(Json(new { result = false, message = "请填写必填项!" }));
            }
            var siteSetting = await GetSiteSetting();

            siteSetting.Name            = input.Name;
            siteSetting.Suffix          = input.Suffix;
            siteSetting.DomainName      = input.DomainName;
            siteSetting.KeyWords        = input.KeyWords;
            siteSetting.Description     = input.Description;
            siteSetting.Copyright       = input.Copyright;
            siteSetting.SiteEmail       = input.SiteEmail;
            siteSetting.ICP             = input.ICP;
            siteSetting.Statistics      = input.Statistics;
            siteSetting.CustomerService = input.CustomerService.Trim();
            _siteSetting.EditAndSave(siteSetting);
            if (siteSetting.CustomerService.Trim() == string.Empty)
            {
                var siteConfiguration = await GetSiteConfiguration();

                if (siteConfiguration.IsOpenCS)
                {
                    siteConfiguration.IsOpenCS = false;
                    _siteConfiguration.EditAndSave(siteConfiguration);
                }
            }
            return(Json(new { result = true }));
        }
Esempio n. 2
0
        /// <summary>
        /// 全站获取网站信息
        /// </summary>
        /// <returns></returns>
        public async Task <SiteSettingVM> GetSiteSettings()
        {
            var viewModel = new SiteSettingVM(await GetSiteSetting());
            var images    = await _businessImage.GetAllAsyn();

            if (images.Count() > 0)
            {
                var image = images.FirstOrDefault(x => x.RelevanceObjectId == viewModel.Id);
                if (image != null)
                {
                    viewModel.LogoPath = string.IsNullOrEmpty(image.UploadPath) ? string.Empty : image.UploadPath;
                }
            }
            return(viewModel);
        }
Esempio n. 3
0
        /// <summary>
        /// 获取网站的基础信息设置
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> SiteSetting()
        {
            var query = await _siteSetting.GetAllAsyn();

            var siteSetting = query.FirstOrDefault();
            var viewModel   = new SiteSettingVM();

            if (siteSetting != null)
            {
                viewModel      = new SiteSettingVM(siteSetting);
                viewModel.Logo = _businessImage.FindBy(x => x.RelevanceObjectId == siteSetting.Id).FirstOrDefault();
                //GetSiteConfiguration();
            }
            return(View(viewModel));
        }
Esempio n. 4
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> EditSiteSetting(SiteSettingVM siteSetting, IFormFile Category7, IFormFile SiteLogo, IFormFile Category1
                                                          , IFormFile Category2, IFormFile Category3, IFormFile Category4, IFormFile Category5, IFormFile Category6)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //AboutUs
                    Setting aboutUsSetting = _context.Settings.Where(x => x.Key.Equals("AboutUs")).SingleOrDefault();
                    aboutUsSetting.Value                 = siteSetting.AboutUs;
                    aboutUsSetting.UpdatedAt             = DateTime.Now;
                    _context.Entry(aboutUsSetting).State = EntityState.Modified;
                    //ContactUs
                    Setting contactUsSetting = _context.Settings.Where(x => x.Key.Equals("ContactUs")).SingleOrDefault();
                    contactUsSetting.Value                 = siteSetting.ContactUs;
                    contactUsSetting.UpdatedAt             = DateTime.Now;
                    _context.Entry(contactUsSetting).State = EntityState.Modified;
                    //Footer
                    Setting footerSetting = _context.Settings.Where(x => x.Key.Equals("Footer")).SingleOrDefault();
                    footerSetting.Value                 = siteSetting.Footer;
                    footerSetting.UpdatedAt             = DateTime.Now;
                    _context.Entry(footerSetting).State = EntityState.Modified;
                    //Slider1Text
                    Setting slider1TextSetting = _context.Settings.Where(x => x.Key.Equals("Slider1")).SingleOrDefault();
                    slider1TextSetting.Value                 = siteSetting.Slider1Text;
                    slider1TextSetting.UpdatedAt             = DateTime.Now;
                    _context.Entry(slider1TextSetting).State = EntityState.Modified;
                    //Slider2Text
                    Setting slider2TextSetting = _context.Settings.Where(x => x.Key.Equals("Slider2")).SingleOrDefault();
                    slider2TextSetting.Value                 = siteSetting.Slider2Text;
                    slider2TextSetting.UpdatedAt             = DateTime.Now;
                    _context.Entry(slider2TextSetting).State = EntityState.Modified;
                    //Slider3Text
                    Setting slider3TextSetting = _context.Settings.Where(x => x.Key.Equals("Slider3")).SingleOrDefault();
                    slider3TextSetting.Value                 = siteSetting.Slider3Text;
                    slider3TextSetting.UpdatedAt             = DateTime.Now;
                    _context.Entry(slider3TextSetting).State = EntityState.Modified;

                    //SiteLogo
                    Setting siteLogoSetting = _context.Settings.Where(x => x.Key.Equals("SiteLogo")).SingleOrDefault();
                    if (SiteLogo != null)
                    {
                        siteLogoSetting.Value = upload(SiteLogo);
                    }
                    siteLogoSetting.UpdatedAt             = DateTime.Now;
                    _context.Entry(siteLogoSetting).State = EntityState.Modified;


                    //Category_1
                    Setting category_1Setting = _context.Settings.Where(x => x.Key.Equals("Category1")).SingleOrDefault();
                    if (Category1 != null)
                    {
                        category_1Setting.Value = upload(Category1);
                    }
                    category_1Setting.UpdatedAt             = DateTime.Now;
                    _context.Entry(category_1Setting).State = EntityState.Modified;

                    //Category_2
                    Setting category_2Setting = _context.Settings.Where(x => x.Key.Equals("Category2")).SingleOrDefault();
                    if (Category2 != null)
                    {
                        category_2Setting.Value = upload(Category2);
                    }
                    category_2Setting.UpdatedAt             = DateTime.Now;
                    _context.Entry(category_2Setting).State = EntityState.Modified;

                    //Category3
                    Setting category3Setting = _context.Settings.Where(x => x.Key.Equals("Category3")).SingleOrDefault();
                    if (Category3 != null)
                    {
                        category3Setting.Value = upload(Category3);
                    }
                    category3Setting.UpdatedAt             = DateTime.Now;
                    _context.Entry(category3Setting).State = EntityState.Modified;

                    //Category4
                    Setting category4Setting = _context.Settings.Where(x => x.Key.Equals("Category4")).SingleOrDefault();
                    if (Category4 != null)
                    {
                        category4Setting.Value = upload(Category4);
                    }
                    category4Setting.UpdatedAt             = DateTime.Now;
                    _context.Entry(category4Setting).State = EntityState.Modified;


                    //Category5
                    Setting category5Setting = _context.Settings.Where(x => x.Key.Equals("Category5")).SingleOrDefault();
                    if (Category5 != null)
                    {
                        category5Setting.Value = upload(Category5);
                    }
                    category5Setting.UpdatedAt             = DateTime.Now;
                    _context.Entry(category5Setting).State = EntityState.Modified;

                    //Category6
                    Setting category6Setting = _context.Settings.Where(x => x.Key.Equals("Category6")).SingleOrDefault();
                    if (Category6 != null)
                    {
                        category6Setting.Value = upload(Category6);
                    }
                    category6Setting.UpdatedAt             = DateTime.Now;
                    _context.Entry(category6Setting).State = EntityState.Modified;

                    //Category7
                    Setting category7Setting = _context.Settings.Where(x => x.Key.Equals("Category7")).SingleOrDefault();
                    if (Category7 != null)
                    {
                        category7Setting.Value = upload(Category7);
                    }
                    category7Setting.UpdatedAt             = DateTime.Now;
                    _context.Entry(category7Setting).State = EntityState.Modified;


                    await _context.SaveChangesAsync();
                }
                catch (Exception e)
                {
                    return(Json(new { e.Message, e.InnerException }));
                }
                //return RedirectToAction(nameof(Index));

                return(Json(new { status = "1", message = "اطلاعات با موفقیت ثبت شد." }));
            }
            return(Json(new { status = "1", message = "اطلاعات با موفقیت ثبت شد." }));
        }