Ejemplo n.º 1
0
        public ActionResult Create(GenericControlValueViewModel model, string ReturnUrl)
        {
            ActionResult action;

            try
            {
                if (!base.ModelState.IsValid)
                {
                    base.ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(base.View(model));
                }
                else
                {
                    GenericControlValue modelMap = Mapper.Map <GenericControlValueViewModel, GenericControlValue>(model);
                    this._genericControlValueService.Create(modelMap);

                    base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.Name)));
                    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;
                ExtentionUtils.Log(string.Concat("GenericControlValue.Create: ", exception.Message));
                return(base.View(model));
            }
            return(action);
        }
Ejemplo n.º 2
0
        public static string GetValueItem(this GenericControlValue genericControlValue, int entityId)
        {
            var itemService = DependencyResolver.Current.GetService <IGenericControlValueItemService>();

            var valueItem = itemService.GetByOption(genericControlValue.Id, entityId, isCache: false);

            return(valueItem.Any() ? valueItem.FirstOrDefault().Value : null);
        }