コード例 #1
0
        public int Save(ClientMember entity)
        {

            ValidationResultInfo vri = Validate(entity);
            if (!vri.IsValid)
            {
                throw new DomainValidationException(vri, "ClientMember provided not valid");
            }
            DateTime date = DateTime.Now;
            tblClientMember tbl = _ctx.tblClientMember.FirstOrDefault(s => s.Id == entity.Id || s.ExternalId==entity.ExternalId);
            if (tbl == null)
            {
                tbl = new tblClientMember();
                tbl.IM_DateCreated = date;
                _ctx.tblClientMember.Add(tbl);
            }
            tbl.IM_DateLastUpdated = date;
            tbl.Name = entity.Name;
            tbl.Code = entity.Code;
            tbl.MemberType =(int) entity.MemberType;
            tbl.ClientId = entity.Client.Id;
            tbl.ExternalId = entity.ExternalId;
            _ctx.SaveChanges();

            return tbl.Id;
        }
コード例 #2
0
 public ValidationResultInfo Validate(ClientMember objToValidate)
 {
     return objToValidate.BasicValidation();
 }