Beispiel #1
0
        public ActionResult AddOperator(OperatorModel model)
        {
            bool flag = false;

            try
            {
                model.OperatorId      = Guid.NewGuid();
                model.CreatedDateTime = DateTime.UtcNow;



                AddressModel addressModel = new AddressModel();
                addressModel.AddressId  = Guid.NewGuid();
                addressModel.Address1   = model.Address;
                addressModel.CountryId  = model.CountryId;
                addressModel.StateId    = model.StateId;
                addressModel.CityId     = model.CityId;
                addressModel.DistrictId = model.DistrictId;

                model.AddressId = addressModel.AddressId;
                StringBuilder     xml        = new StringBuilder();
                StringBuilder     xml2       = new StringBuilder();
                XmlSerializer     serializer = new XmlSerializer(typeof(AddressModel));
                XmlWriterSettings settings   = new XmlWriterSettings()
                {
                    Encoding = new UnicodeEncoding(false, false)
                };

                using (XmlWriter xw = XmlWriter.Create(xml, settings))
                {
                    serializer.Serialize(xw, addressModel);
                }

                string OperatorAddressXml = xml.ToString();

                XmlSerializer     serializer2 = new XmlSerializer(typeof(OperatorModel));
                XmlWriterSettings settings2   = new XmlWriterSettings()
                {
                    Encoding = new UnicodeEncoding(false, false)
                };
                using (XmlWriter xw2 = XmlWriter.Create(xml2, settings2))
                {
                    serializer2.Serialize(xw2, model);
                }

                string OperatorDetailXml = xml2.ToString();
                _IOperatorService.AddOperator(OperatorAddressXml, OperatorDetailXml);

                flag = true;
            }
            catch (Exception ex)
            {
                flag = false;
            }
            return(Json(flag, JsonRequestBehavior.AllowGet));
        }