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; }
public ValidationResultInfo Validate(ClientMember objToValidate) { return objToValidate.BasicValidation(); }