Beispiel #1
0
        public ActionResult Revert(CustomerInfo model)
        {
            try
            {
                //var customerInfo = new CustomerInfo();
                CustInfoSerializerFactory serializationFactory = new ConcreteCustInfoSerializerFactory();

                string      serializeTo = model.SerializeDirection.ToString();
                ISerializer direction   = serializationFactory.GetSerializer(serializeTo);
                string      toRevert    = model.Serialized;
                var         result      = direction.Deserialize(toRevert);
                model.Serialized = result.ToString();
                ModelState.Clear();
            }
            catch (Exception ex)
            {
                TempData["ErrorMsg"] = ex.Message;
            }

            return(View("Index", model));
        }
Beispiel #2
0
        public ActionResult Submit(CustomerInfo model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.Serialized = null;
                    CustInfoSerializerFactory serializationFactory = new ConcreteCustInfoSerializerFactory();
                    string      serializeTo = model.SerializeDirection.ToString();
                    ISerializer direction   = serializationFactory.GetSerializer(serializeTo);
                    string      result      = direction.Serialize(model);
                    model.Serialized = result;
                    ModelState.Clear();
                }
                catch (Exception ex)
                {
                    TempData["ErrorMsg"] = ex.Message;
                }
            }

            return(View("Index", model));
        }