/// <summary>
        /// Ladet die Photographers aus dem Configfile
        /// </summary>
        /// <returns></returns>
        private List <PhotographerViewModel> loadPhotographers()
        {
            BusinessLayer bl = new BusinessLayer();

            bl.Sync();
            var models = bl.GetPhotographers();
            List <PhotographerViewModel> list = new List <PhotographerViewModel>();

            if (models != null)
            {
                foreach (PhotographerModel model in models)
                {
                    var photographerViewModel = new PhotographerViewModel(model);
                    list.Add(photographerViewModel);
                }
            }

            //shit pfad
            string[]              lines = System.IO.File.ReadAllLines(@"C:\Users\Mausi\Desktop\SWE-PRUEFUNG\PicDB\photographers.config");
            PhotographerModel     p;
            PhotographerViewModel pvm;

            foreach (string line in lines)
            {
                string[] element = line.Split(';');
                p           = new PhotographerModel();
                p.FirstName = element[0];
                p.LastName  = element[1];
                p.Notes     = element[3];
                pvm         = new PhotographerViewModel(p);
                list.Add(pvm);
            }


            return(list);
        }
예제 #2
0
 public void SavePhotographer(int id, PhotographerModel photographer)
 {
     _dal.SavePhotographer(id, photographer);
 }
예제 #3
0
 public void SaveNewPhotographer(PhotographerModel pm)
 {
     _dal.SaveNewPhotographer(pm);
 }
예제 #4
0
 public PhotographerViewModel(PhotographerModel mdl)
 {
     this.mdl = mdl;
 }
예제 #5
0
 internal void SavePhotographer(PhotographerModel photographer)
 {
     ((DataAccessLayer)DataAccessLayer).SavePhotographer(photographer);
 }
예제 #6
0
 public void UpdatePhotographer(PhotographerModel photographerModel)
 {
     ((DataAccessLayer)DataAccessLayer).UpdatePhotographer(photographerModel);
 }
예제 #7
0
        /// <summary>
        /// update an existing photographer entry
        /// </summary>
        /// <param name="photographer"></param>
        private void UpdatePhotographer(IPhotographerModel photographer)
        {
            PhotographerModel p = (PhotographerModel)photographer;

            SqlCommand c = new SqlCommand(null, dbc);

            c.CommandText = "UPDATE Photographers SET FirstName = @FirstName, LastName = @LastName, Birthdate = @Birthdate, Notes = @Notes WHERE ID = @ID";

            SqlParameter ID = new SqlParameter("@ID", SqlDbType.Int, 0);

            ID.Value = photographer.ID;
            c.Parameters.Add(ID);

            SqlParameter FirstName = new SqlParameter("@FirstName", SqlDbType.VarChar, string.IsNullOrEmpty(photographer.FirstName) ? 1 : photographer.FirstName.Length);

            if (photographer.FirstName == null)
            {
                FirstName.Value = DBNull.Value;
            }
            else
            {
                FirstName.Value = photographer.FirstName;
            }
            c.Parameters.Add(FirstName);

            SqlParameter LastName = new SqlParameter("@LastName", SqlDbType.VarChar, photographer.LastName.Length);

            LastName.Value = photographer.LastName;
            c.Parameters.Add(LastName);

            SqlParameter Bithdate = new SqlParameter("@Birthdate", SqlDbType.Date, 0);

            if (photographer.BirthDay == null)
            {
                Bithdate.Value = DBNull.Value;
            }
            else
            {
                Bithdate.Value = photographer.BirthDay;
            }
            c.Parameters.Add(Bithdate);

            SqlParameter Notes = new SqlParameter("@Notes", SqlDbType.Text, string.IsNullOrEmpty(photographer.Notes) ? 1 : photographer.Notes.Length);

            if (photographer.Notes == null)
            {
                Notes.Value = DBNull.Value;
            }
            else
            {
                Notes.Value = photographer.Notes;
            }
            c.Parameters.Add(Notes);

            c.Prepare();
            try
            {
                c.ExecuteReader();
                _Photographers[photographer.ID] = (PhotographerModel)photographer;
            }
            catch (SqlException e)
            {
                Trace.WriteLine(e.Message);
            }
        }
예제 #8
0
        /// <summary>
        /// insert a new photographer entry into database
        /// </summary>
        /// <param name="photographer"></param>
        private void InsertPhotograper(IPhotographerModel photographer)
        {
            PhotographerModel p = (PhotographerModel)photographer;

            SqlCommand c = new SqlCommand(null, dbc);

            c.CommandText = "INSERT INTO Photographers (FirstName, LastName, Birthdate, Notes) OUTPUT INSERTED.ID VALUES(@FirstName, @LastName, @Birthdate, @Notes)";

            SqlParameter FirstName = new SqlParameter("@FirstName", SqlDbType.VarChar, string.IsNullOrEmpty(photographer.FirstName) ? 1 : photographer.FirstName.Length);

            if (photographer.FirstName != null)
            {
                FirstName.Value = photographer.FirstName;
            }
            else
            {
                FirstName.Value = DBNull.Value;
            }
            c.Parameters.Add(FirstName);

            SqlParameter LastName = new SqlParameter("@LastName", SqlDbType.VarChar, photographer.LastName.Length);

            LastName.Value = photographer.LastName;
            c.Parameters.Add(LastName);

            SqlParameter Birthdate = new SqlParameter("@Birthdate", SqlDbType.Date, 0);

            if (photographer.BirthDay != null)
            {
                Birthdate.Value = photographer.BirthDay;
            }
            else
            {
                Birthdate.Value = DBNull.Value;
            }
            c.Parameters.Add(Birthdate);

            SqlParameter Notes = new SqlParameter("@Notes", SqlDbType.Text, string.IsNullOrEmpty(photographer.Notes) ? 1 : photographer.Notes.Length);

            if (photographer.Notes != null)
            {
                Notes.Value = photographer.Notes;
            }
            else
            {
                Notes.Value = DBNull.Value;
            }
            c.Parameters.Add(Notes);

            c.Prepare();
            try
            {
                Int32 ID = (Int32)c.ExecuteScalar();
                photographer.ID = ID;
                _Photographers.Add(photographer.ID, (PhotographerModel)photographer);
            }
            catch (SqlException e)
            {
                Trace.WriteLine(e.Message);
            }
        }