public void Get()
        {
            var manager = new ComicStripManager(new UnitOfWork("development"));

            manager.DeleteAll();
            var publisherManager = new PublisherManager(new UnitOfWork("development"));

            publisherManager.DeleteAll();
            publisherManager.Add(new Publisher("test-publisher"));

            var AuthorManager = new AuthorManager(new UnitOfWork("development"));

            AuthorManager.DeleteAll();

            AuthorManager.Add(new Author("test-author", "test-author"));

            manager.Add(new BusinessLayer.Models.ComicStrip("test-strip", new ComicstripSerie("testSerie"), 5, AuthorManager.GetAll(), publisherManager.GetAll()[0]));
            var comic = manager.GetAll();

            var bundleManager = new ComicstripBundleManager(new UnitOfWork("development"));

            bundleManager.DeleteAll();
            bundleManager.Add(new ComicstripBundle("test-bundle", comic, publisherManager.GetAll()[0]));
            var bundles = bundleManager.GetAll();
            var bundle  = bundleManager.Get(bundles[0].ID);

            Assert.AreEqual(bundles.Count, 1);
            Assert.AreEqual(bundle.Titel, "test-bundle");
            Assert.AreEqual(bundle.Comicstrips.Count, 1);

            manager.DeleteAll();
            AuthorManager.DeleteAll();
            bundleManager.DeleteAll();
        }
        public void Update()
        {
            var manager = new AuthorManager(new UnitOfWork("development"));

            manager.DeleteAll();
            manager.Add(new BusinessLayer.Models.Author("test-first", "test-Last"));
            var authors = manager.GetAll();

            Assert.AreEqual(authors.Count, 1);
            var author = manager.Get(authors[0].ID);

            Assert.AreEqual(author.Firstname, "test-first");
            Assert.AreEqual(author.Surname, "test-Last");
            author.SetSurname("test-Sur");
            author.SetFirstName("test-First");
            manager.Update(author);

            authors = manager.GetAll();

            Assert.AreEqual(authors.Count, 1);
            author = manager.Get(authors[0].ID);
            Assert.AreEqual(author.Firstname, "test-First");
            Assert.AreEqual(author.Surname, "test-Sur");

            manager.DeleteAll();
        }
Ejemplo n.º 3
0
        public void DeleteByID()
        {
            var manager = new ComicStripManager(new UnitOfWork("development"));

            manager.DeleteAll();
            var publisherManager = new PublisherManager(new UnitOfWork("development"));

            publisherManager.DeleteAll();
            publisherManager.Add(new Publisher("test-publisher"));

            var AuthorManager = new AuthorManager(new UnitOfWork("development"));

            AuthorManager.DeleteAll();
            AuthorManager.Add(new Author("test-author", "test-author"));

            manager.Add(new BusinessLayer.Models.ComicStrip("test-strip", new ComicstripSerie("testSerie"), 5, AuthorManager.GetAll(), publisherManager.GetAll()[0]));
            var comic = manager.GetAll();

            Assert.AreEqual(comic.Count, 1);
            var comc = manager.Get(comic[0].ID);

            Assert.AreEqual(comc.Titel, "test-strip");
            Assert.AreEqual(comc.Number, 5);
            manager.Delete(comc.ID);
            comic = manager.GetAll();
            Assert.AreEqual(comic.Count, 0);

            publisherManager.DeleteAll();
            AuthorManager.DeleteAll();
            manager.DeleteAll();
        }
        public void AddAuthor()
        {
            var manager = new AuthorManager(new UnitOfWork("development"));

            manager.DeleteAll();
            manager.Add(new BusinessLayer.Models.Author("test-first", "test-Last"));
            var authors = manager.GetAll();

            Assert.AreEqual(authors.Count, 1);
            Assert.AreEqual(authors[0].Firstname, "test-first");
            Assert.AreEqual(authors[0].Surname, "test-Last");
            manager.DeleteAll();
        }
Ejemplo n.º 5
0
 private void Submit(object sender, RoutedEventArgs e)
 {
     try
     {
         AuthorManager am = new AuthorManager(new UnitOfWork());
         am.Add(new Author(this.FirstnameInput.Text, this.LastnameInput.Text));
         MessageUtil.ShowAsyncMessage("Author has been added");
         Reset();
     }
     catch (Exception ex)
     {
         MessageUtil.ShowAsyncMessage(ex.Message);
     }
 }
Ejemplo n.º 6
0
        protected void Insert(object sender, EventArgs e)
        {
            if (!(String.IsNullOrWhiteSpace(txtName.Text) && String.IsNullOrWhiteSpace(txtLastName.Text)))
            {
                authorManager = new AuthorImpXMLManager();

                Author author = new Author()
                {
                    Name      = txtName.Text,
                    LastName  = txtLastName.Text,
                    BirthDate = Convert.ToDateTime(Request.Form["txtBirthdate"])
                };
                authorManager.Add(author);
                errorMe.Text = "";
            }
            else
            {
                errorMe.Text = "No se pueden dejar campos vacios";
            }


            this.BindGrid();
        }
Ejemplo n.º 7
0
 public HttpResponseMessage Post([FromBody] AuthorModel model)
 {
     try
     {
         AuthorDTO dto      = modelfactory.Parse(model);
         var       authorID = authormanager.Add(dto);
         if (authorID != null)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, "Author Added Successfully"));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, "Adding Author Failed"));
         }
     }
     catch (InvalidAuthorException ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
Ejemplo n.º 8
0
        public static void import(string location)
        {
            UnitOfWork        uow = new UnitOfWork();
            ComicStripManager CM  = new ComicStripManager(uow);
            AuthorManager     AM  = new AuthorManager(uow);
            PublisherManager  PM  = new PublisherManager(uow);

            //Publisher , Author en comicStrip aan de databank toe voegen
            foreach (ComicStrip comicStrip in ReadJson(location))
            {
                try
                {
                    // Publisher toe voegen
                    if (!PM.Exist(comicStrip.Publisher, true))
                    {
                        comicStrip.SetPublisher(PM.Add(comicStrip.Publisher));
                    }
                    else
                    {
                        comicStrip.SetPublisher(PM.GetByName(comicStrip.Publisher.Name));
                    }

                    // Authors toe voegen
                    List <Author> tempAuthor = new List <Author>();
                    foreach (Author author in comicStrip.Authors)
                    {
                        if (AM.Exist(author, true))
                        {
                            tempAuthor.Add(AM.GetByName(author.Firstname, author.Surname));
                        }
                        else
                        {
                            tempAuthor.Add(AM.Add(author));
                        }
                    }
                    // Reeks toe voegen
                    if (!CM.ExistSerie(comicStrip.Serie, true))
                    {
                        comicStrip.SetSerie(CM.AddSerie(comicStrip.Serie));
                    }
                    else
                    {
                        comicStrip.SetSerie(CM.GetSerieByName(comicStrip.Serie.Name));
                    }
                    // Commiting Changes
                    comicStrip.SetAuthors(tempAuthor);
                    CM.Add(comicStrip);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            //get file dir
            List <string> split = location.Split("\\").ToList();

            split.RemoveAt(split.Count - 1);
            string newLocation = "";

            foreach (string s in split)
            {
                newLocation += s + "\\";
            }

            //get all bad comics
            List <Strip> rejectstrips = new List <Strip>();

            foreach (var key in Errors.Keys)
            {
                foreach (Strip strip in Errors[key])
                {
                    rejectstrips.Add(strip);
                }
            }

            //dump data
            string        newrawJson = JsonConvert.SerializeObject(rejectstrips);
            DirectoryInfo dir        = new DirectoryInfo(newLocation);

            File.WriteAllText(dir + "\\RejectDump.json", newrawJson);
        }