Exemplo n.º 1
0
        public ActionResult Edit(SettingSeoGlobalViewModel seoSetting, string ReturnUrl)
        {
            ActionResult action;

            try
            {
                if (!base.ModelState.IsValid)
                {
                    base.ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(base.View(seoSetting));
                }
                else
                {
                    SettingSeoGlobal byId = this._settingSeoGlobal.GetById(seoSetting.Id);
                    if (seoSetting.Status == 1 && seoSetting.Status != byId.Status)
                    {
                        IEnumerable <SettingSeoGlobal> settingSeoGlobals = this._settingSeoGlobal.FindBy((SettingSeoGlobal x) => x.Status == 1, false);
                        if (settingSeoGlobals.IsAny <SettingSeoGlobal>())
                        {
                            foreach (SettingSeoGlobal settingSeoGlobal in settingSeoGlobals)
                            {
                                settingSeoGlobal.Status = 0;
                                this._settingSeoGlobal.Update(settingSeoGlobal);
                            }
                        }
                    }
                    SettingSeoGlobal settingSeoGlobal1 = Mapper.Map <SettingSeoGlobalViewModel, SettingSeoGlobal>(seoSetting, byId);
                    this._settingSeoGlobal.Update(settingSeoGlobal1);
                    base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.SettingSeoGlobal)));
                    if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\"))
                    {
                        action = base.RedirectToAction("Index");
                    }
                    else
                    {
                        action = this.Redirect(ReturnUrl);
                    }
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                base.ModelState.AddModelError("", exception.Message);
                ExtentionUtils.Log(string.Concat("SeoGlobal.Edit: ", exception.Message));
                return(base.View(seoSetting));
            }
            return(action);
        }
Exemplo n.º 2
0
        public ActionResult Create(SettingSeoGlobalViewModel seoSetting, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(seoSetting));
                }

                if (seoSetting.Status == 1)
                {
                    var settingSeoGlobals = _settingSeoGlobal.FindBy(x => x.Status == 1);
                    if (settingSeoGlobals.IsAny())
                    {
                        foreach (var settingSeoGlobal in settingSeoGlobals)
                        {
                            settingSeoGlobal.Status = 0;
                            _settingSeoGlobal.Update(settingSeoGlobal);
                        }
                    }
                }
                var settingSeoGlobal1 = Mapper.Map <SettingSeoGlobalViewModel, SettingSeoGlobal>(seoSetting);
                _settingSeoGlobal.Create(settingSeoGlobal1);

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.SettingSeoGlobal)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception exception1)
            {
                var exception = exception1;
                ExtentionUtils.Log(string.Concat("SeoGlobal.Create: ", exception.Message));
                ModelState.AddModelError("", exception.Message);
                return(View(seoSetting));
            }
            return(action);
        }
Exemplo n.º 3
0
        public ActionResult Edit(int Id)
        {
            SettingSeoGlobalViewModel settingSeoGlobalViewModel = Mapper.Map <SettingSeoGlobal, SettingSeoGlobalViewModel>(this._settingSeoGlobal.GetById(Id));

            return(base.View(settingSeoGlobalViewModel));
        }