Exemplo n.º 1
0
        public Guid Create(Model.Member memberEntity)
        {
            var context = new CMS_DataContext();

            var member = new DataAccess.Member()
            {
                Id               = memberEntity.Id,
                FirstName        = memberEntity.FirstName,
                MiddleName       = memberEntity.MiddleName,
                LastName         = memberEntity.LastName,
                Age              = memberEntity.Age,
                Gender           = memberEntity.Gender,
                Birthday         = string.IsNullOrEmpty(memberEntity.Birthday)? (DateTime?)null: DateTime.Parse(memberEntity.Birthday),
                MobilePhone      = memberEntity.MobilePhone,
                LandLine         = memberEntity.LandLine,
                Address          = memberEntity.Address,
                MaritalStatus    = memberEntity.MaritalStatus,
                NameOfSpouse     = memberEntity.NameOfSpouse,
                SpouseContact    = memberEntity.SpouseContact,
                ChildrenCount    = memberEntity.ChildrenCount,
                MemberStatus     = memberEntity.MemberStatus,
                BaptizedDate     = string.IsNullOrEmpty(memberEntity.BaptizedDate)?(DateTime?)null:DateTime.Parse(memberEntity.BaptizedDate),
                BaptizedPlace    = memberEntity.BaptizedPlace,
                BaptizedMinister = memberEntity.BaptizedMinister,
                BelongsToGroups  = memberEntity.BelongsToGroups,
                Positions        = memberEntity.Positions
            };

            context.Members.InsertOnSubmit(member);
            context.SubmitChanges();
            return(memberEntity.Id);
        }
Exemplo n.º 2
0
        public Guid Update(Model.Member memberEntity)
        {
            var context = new CMS_DataContext();
            var member  = context.Members.Where(x => x.Id == memberEntity.Id).FirstOrDefault();

            member.FirstName        = memberEntity.FirstName;
            member.MiddleName       = memberEntity.MiddleName;
            member.LastName         = memberEntity.LastName;
            member.Age              = memberEntity.Age;
            member.Gender           = memberEntity.Gender;
            member.Birthday         = string.IsNullOrEmpty(memberEntity.Birthday)? (DateTime?)null: DateTime.Parse(memberEntity.Birthday);
            member.MobilePhone      = memberEntity.MobilePhone;
            member.LandLine         = memberEntity.LandLine;
            member.Address          = memberEntity.Address;
            member.MaritalStatus    = memberEntity.MaritalStatus;
            member.NameOfSpouse     = memberEntity.NameOfSpouse;
            member.SpouseContact    = memberEntity.SpouseContact;
            member.ChildrenCount    = memberEntity.ChildrenCount;
            member.MemberStatus     = memberEntity.MemberStatus;
            member.BaptizedDate     = string.IsNullOrEmpty(memberEntity.BaptizedDate) ? (DateTime?)null : DateTime.Parse(memberEntity.BaptizedDate);
            member.BaptizedPlace    = memberEntity.BaptizedPlace;
            member.BaptizedMinister = memberEntity.BaptizedMinister;
            member.BelongsToGroups  = memberEntity.BelongsToGroups;
            member.Positions        = memberEntity.Positions;

            context.SubmitChanges();
            return(memberEntity.Id);
        }