private XElement ConvertToXml(Guid id, IEducationEntity ent) { return(new XElement("EducationItem", new XAttribute("Guid", id.ToString()), new XElement("Credential", ent.Credential), new XElement("Institution", ent.Institution))); }
private void Reset() { repos = null; id = Guid.Empty; selectedInstitution = null; selectedCredential = null; updatedCredential = null; }
public void EducationRepository_Update_Exception1() { Guid g = Guid.NewGuid(); IEducationEntity newEE = null; // bad! var mockXml = new Mock <IEducationXMLService>(); mockXml.Setup(T => T.Update(g, newEE)).Throws(new ArgumentNullException()); var repos = new EducationRepository(mockXml.Object); repos.Update(g, newEE); }
public void Update(Guid guid, IEducationEntity entity) { try { xs.Update(guid, entity); } catch (Exception) { throw; } }
public Guid Add(IEducationEntity entity) { try { return(xs.Insert(entity)); } catch (Exception) { throw; } }
public Guid Insert(IEducationEntity entity) { var doc = persister.Load <IEducationEntity>(); var guid = Guid.NewGuid(); var newElement = ConvertToXml(guid, entity); doc.Root.Add(newElement); persister.Persist <IEducationEntity>(doc); return(guid); }
public void Update(Guid guid, IEducationEntity entity) { if (guid == null) { throw new ArgumentNullException("guid"); } if (entity == null) { throw new ArgumentNullException("entity"); } var doc = persister.Load <IEducationEntity>(); XElement oldEl = GetXElement(doc, guid); if (oldEl == null) { throw new ArgumentException("guid not found."); } oldEl.ReplaceWith(ConvertToXml(guid, entity)); persister.Persist <IEducationEntity>(doc); }
private void Reset() { repos = null; selectedInstitution = null; selectedCredential = null; }