Beispiel #1
0
        public ActionResult PaymentRulesManagement()
        {
            var blParticipantRule = new BLParticipantRule();

            return(View("PaymentRulesManagement", new VmPaymentRulesManagement()
            {
                ParticipantRule = blParticipantRule.GetParticipantRule()
            }));
        }
        public ActionResult UpdateParticipantRule([Bind(Exclude = "ExtraParticipantFee")] VmParticipantRule model)
        //public ActionResult UpdateParticipantRule( VmParticipantRule model)
        {
            var message = "";
            var result  = true;

            try
            {
                model.ExtraParticipantFee = decimal.Parse(model.UIExtraParticipantFee, System.Globalization.NumberStyles.Currency);

                if (!ModelState.IsValid)
                {
                    var jsonEx = JsonConvert.SerializeObject(ModelState, Formatting.Indented,
                                                             new JsonSerializerSettings
                    {
                        ReferenceLoopHandling = ReferenceLoopHandling.Serialize
                    });

                    var jsonException = new
                    {
                        participantRuleId = model.Id,
                        success           = false,
                        message           = message + "\n" + jsonEx
                    };

                    return(Json(jsonException, JsonRequestBehavior.AllowGet));
                }

                var blParticipantRule = new BLParticipantRule();

                result = blParticipantRule.UpdateParticipantRule(model);


                if (result == false)
                {
                    message = model.ActionMessageHandler.Message = "Operation has been failed...\n call system Admin";
                }
                else
                {
                    message = model.ActionMessageHandler.Message = "Operation has been succeeded";
                }

                var jsonData = new
                {
                    participantRuleId = model.Id,
                    success           = result,
                    message
                };

                return(Json(jsonData, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var jsonEx = JsonConvert.SerializeObject(ex, Formatting.Indented,
                                                         new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                });

                var jsonException = new
                {
                    paymentRuleId = model.Id,
                    success       = false,
                    message       = message + "\n" + jsonEx
                };

                return(Json(jsonException, JsonRequestBehavior.AllowGet));
            }
        }