public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { Address address = (Address)value; AddressJsonModel jsonModel = new AddressJsonModel { ChainId = address.ChainId, Local = CryptoUtils.HexStringToBytes(address.LocalAddress) }; serializer.Serialize(writer, jsonModel); }
public JsonResult GetShipAddress(int ShipId) { var address = _unitOfWork.GetRepo <Address>().GetObject(x => x.Id == ShipId); var model = new AddressJsonModel { FullName = address.FirstName + " " + address.LastName, Email = address.Email, PhoneNumber = address.PhoneNumber, CityTown = address.City + " / " + address.Town, Address1 = address.Address1, Address2 = address.Address2, PostalCode = address.PostalCode }; return(Json(model, JsonRequestBehavior.AllowGet)); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { AddressJsonModel jsonModel = serializer.Deserialize <AddressJsonModel>(reader); return(new Address(CryptoUtils.BytesToHexString(jsonModel.Local), String.IsNullOrEmpty(jsonModel.ChainId) ? Address.kDefaultChainId : jsonModel.ChainId)); }