Beispiel #1
0
    public static CMS.DataAccess.Member ConvertToMemberEntity(this JsonMemberRequest request)
    {
        var Id = string.IsNullOrEmpty(request.Id) ? Guid.NewGuid() : new Guid(request.Id);

        return(new CMS.DataAccess.Member()
        {
            Id = Id,
            FirstName = request.FirstName,
            MiddleName = request.MiddleName,
            LastName = request.LastName,
            Age = request.Age.ToInt(),
            Gender = request.Gender,
            Birthday = request.Birthday.ToDateTime(),
            MobilePhone = request.MobilePhone,
            LandLine = request.LandLine,
            Address = request.Address,
            MaritalStatus = request.MaritalStatus,
            NameOfSpouse = request.NameOfSpouse,
            SpouseContact = request.SpouseContact,
            ChildrenCount = request.ChildrenCount.ToInt(),
            MemberStatus = request.MemberStatus,
            BaptizedDate = request.BaptizedDate.ToDateTime(),
            BaptizedPlace = request.BaptizedPlace,
            BaptizedMinister = request.BaptizedMinister,
            BelongsToGroups = request.BelongsToGroups,
            Positions = request.Positions
        });
    }
Beispiel #2
0
    public static JsonMemberRequest ConvertToJson(this CMS.DataAccess.Member member)
    {
        try
        {
            var json = new JsonMemberRequest();

            json.Id               = member.Id.ToString();
            json.FirstName        = member.FirstName;
            json.MiddleName       = member.MiddleName.SafeToString();
            json.LastName         = member.LastName.SafeToString();
            json.Age              = member.Age.SafeToString();
            json.Gender           = member.Gender.SafeToString();
            json.Birthday         = member.Birthday.HasValue? member.Birthday.Value.ToShortDateString(): string.Empty;
            json.MobilePhone      = member.MobilePhone.SafeToString();
            json.LandLine         = member.LandLine.SafeToString();
            json.Address          = member.Address.SafeToString();
            json.MaritalStatus    = member.MaritalStatus.SafeToString();
            json.NameOfSpouse     = member.NameOfSpouse.SafeToString();
            json.SpouseContact    = member.SpouseContact.SafeToString();
            json.ChildrenCount    = member.ChildrenCount.SafeToString();
            json.MemberStatus     = member.MemberStatus.SafeToString();
            json.BaptizedDate     = member.BaptizedDate.HasValue? member.BaptizedDate.Value.ToShortDateString(): string.Empty;
            json.BaptizedPlace    = member.BaptizedPlace.SafeToString();
            json.BaptizedMinister = member.BaptizedMinister.SafeToString();
            json.BelongsToGroups  = member.BelongsToGroups.SafeToString();
            json.Positions        = member.Positions.SafeToString();
            return(json);
        }
        catch (Exception e)
        {
            throw e;
        }
    }