Example #1
0
 /// <summary>
 /// Update existing ComicstripSerie
 /// </summary>
 public void UpdateSerie(ComicstripSerie cs)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("UPDATE [dbo].[ComicstripSeries] SET Name = @Name WHERE Id = @Id", this.context);
         cmd.Parameters.AddWithValue("@Name", cs.Name);
         cmd.Parameters.AddWithValue("@Id", cs.ID);
         context.Open();
         cmd.ExecuteNonQuery();
         context.Close();
     }
     catch (Exception) { throw new QueryException(); }
 }
Example #2
0
 /// <summary>
 /// Check if ComicstripSerie exist
 /// </summary>
 public bool ExistSerie(ComicstripSerie cs, bool ignoreId = false)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM [dbo].[ComicstripSeries] WHERE LOWER(Name) = @Name OR Id = @Id", this.context);
         cmd.Parameters.AddWithValue("@Name", cs.Name.ToLower());
         cmd.Parameters.AddWithValue("@Id", (!ignoreId) ? cs.ID : -1);
         context.Open();
         int count = (int)cmd.ExecuteScalar();
         context.Close();
         return(count > 0);
     }
     catch (Exception) { throw new QueryException(); }
 }
 /// <summary>
 /// Add a new ComicstripSerie
 /// </summary>
 public ComicstripSerie AddSerie(ComicstripSerie cs)
 {
     // Check if comicstrip serie exists
     if (uow.Comicstrips.ExistSerie(cs))
     {
         throw new ExistException("comicstrip serie");
     }
     try
     {
         // Add comicstrip serie and return object with generated id
         return(uow.Comicstrips.AddSerie(cs));
     }
     catch (Exception) { throw new AddException("comicstrip serie"); }
 }
Example #4
0
        /// <summary>
        /// Add a new ComicstripSerie
        /// </summary>
        public ComicstripSerie AddSerie(ComicstripSerie cs)
        {
            int    id  = -1;
            String cmd = "INSERT INTO [dbo].[ComicstripSeries] (Name) VALUES (@Name);SELECT CAST(scope_identity() AS int)";

            using (var insertCmd = new SqlCommand(cmd, this.context))
            {
                insertCmd.Parameters.AddWithValue("@Name", cs.Name);
                try
                {
                    context.Open();
                    id = (int)insertCmd.ExecuteScalar();
                    context.Close();
                }
                catch (Exception) { throw new InsertException(); }
            }
            if (id < 0)
            {
                throw new ComicstripSerieAddException();
            }
            return(new ComicstripSerie(id, cs.Name));
        }
 private void Submit(object sender, RoutedEventArgs e)
 {
     try
     {
         Publisher         p  = this.publishers[this.PublisherInput.SelectedIndex];
         ComicStripManager sm = new ComicStripManager(new UnitOfWork());
         ComicstripSerie   cs = null;
         if (!((bool)this.SerieSwitcher.IsChecked))
         {
             cs = this.series[this.SerieInputSelect.SelectedIndex];
         }
         else
         {
             cs = new ComicstripSerie(this.SerieInputNew.Text);
         }
         sm.Add(new ComicStrip(this.TitleInput.Text, cs, int.Parse(this.NumberInput.Text), this.AuthorsInput.GetSelected(), p));
         MessageUtil.ShowAsyncMessage("Comicstrip has been added");
         Reset();
     }
     catch (Exception ex)
     {
         MessageUtil.ShowAsyncMessage(ex.Message);
     }
 }
Example #6
0
 public static Reeks FromDomain(ComicstripSerie serie)
 {
     return(new Reeks {
         ID = serie.ID, Naam = serie.Name
     });
 }
 /// <summary>
 /// Check if ComicstripSerie exist
 /// </summary>
 public bool ExistSerie(ComicstripSerie cs, bool ignoreId = false)
 {
     return(uow.Comicstrips.ExistSerie(cs, ignoreId));
 }