Exemplo n.º 1
0
 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)));
 }
Exemplo n.º 2
0
 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);
        }
Exemplo n.º 4
0
 public void Update(Guid guid, IEducationEntity entity)
 {
     try
     {
         xs.Update(guid, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 5
0
 public Guid Add(IEducationEntity entity)
 {
     try
     {
         return(xs.Insert(entity));
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 private void Reset()
 {
     repos = null;
     selectedInstitution = null;
     selectedCredential  = null;
 }