public ActionResult Edit(AttributeValueViewModel attributeValue, string returnUrl)
        {
            ActionResult action;

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

                var attributeValue1 = Mapper.Map <AttributeValueViewModel, AttributeValue>(attributeValue);
                _attributeValueService.Update(attributeValue1);

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.AttributeValue)));
                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;
                LogText.Log(string.Concat("District.Edit: ", exception.Message));
                return(View(attributeValue));
            }
            return(action);
        }
Beispiel #2
0
        public async Task <IActionResult> UpdateValue(string id, string valueId, [FromBody] AttributeValueMeta attributeValueMeta)
        {
            var result = await _attributeValueService.Update(CurrentUser.TenantId, id, CurrentUser.Id, CurrentUser.FullName, CurrentUser.Avatar, valueId, attributeValueMeta);

            if (result.Code <= 0)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }