Ejemplo n.º 1
0
        /// <summary>
        /// From ManageRuleFormData to RuleRequestData
        /// </summary>
        /// <param name="formData">the formData to convert</param>
        /// <returns>the ManageRuleFormData result.</returns>
        public static RuleRequestData ToRequestData(this ManageRuleFormData formData)
        {
            RuleRequestData requestData = new RuleRequestData();

            if (formData != null)
            {
                requestData = new RuleRequestData
                {
                    RuleDto = new RuleItemData
                    {
                        RulePrefix = formData.RulePrefix,
                        RuleName   = formData.RuleName,
                        RuleId     = formData.RuleId
                    }
                };
            }
            return(requestData);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The update rule view.
        /// </summary>
        /// <param name="ruleId">the rule id to update.</param>
        /// <returns>updating view</returns>
        public async Task <ActionResult> GetUpdateRule(int ruleId)
        {
            ManageRuleFormData ruleFormData = new ManageRuleFormData();
            RuleRequestData    findRequest  = new RuleRequestData
            {
                RuleDto = new RuleItemData
                {
                    RuleId = ruleId
                },
                FindRuleItemData = FindRuleItemData.RuleId
            };

            RuleResultData result = await WebApiClient.PostFormJsonAsync <RuleRequestData, RuleResultData>(Constant.WebApiControllerRule, Constant.WebApiFindRules, findRequest);

            if (result != null && result.OperationSuccess && result.RuleDto != null)
            {
                ruleFormData = result.ToFormData();
            }
            ViewBag.action = "UpdateRule";
            return(PartialView("Partials/_ManageRule", ruleFormData));
        }
Ejemplo n.º 3
0
        public async Task <OmsJsonResult> UpdateRule(ManageRuleFormData ruleFormData)
        {
            RuleRequestData request = ruleFormData.ToRequestData();
            RuleResultData  result  = await WebApiClient.PostFormJsonAsync <RuleRequestData, RuleResultData>(Constant.WebApiControllerRule, Constant.WebApiUpdateRule, request);

            JsonReturnData data = new JsonReturnData();

            if (result == null)
            {
                data.ErrorMessage     = SharedResources.ServerError;
                data.OperationSuccess = false;
            }
            else if (!result.OperationSuccess && result.Errors != null && result.Errors.Count > 0)
            {
                data.ErrorMessage     = result.Errors.First();
                data.OperationSuccess = false;
            }
            else if (result.OperationSuccess)
            {
                data.SuccessMessage   = RuleResources.Ok;
                data.OperationSuccess = true;
            }
            return(new OmsJsonResult(data));
        }