/// <summary>
 /// Generic Delete method for the entities
 /// </summary>
 /// <param name="entityToDelete"></param>
 public virtual void Delete(TEntity entityToDelete)
 {
     if (Context.Entry(entityToDelete).State == EntityState.Detached)
     {
         DbSet.Attach(entityToDelete);
     }
     DbSet.Remove(entityToDelete);
 }
Beispiel #2
0
        /// <summary>
        ///Remove an Office
        /// </summary>
        public void RemoveOffice(Office office)
        {
            _dbContext = new BeerTapDBContext();

            _dbContext.Entry(office).State = System.Data.Entity.EntityState.Deleted;
            _dbContext.SaveChanges();
        }
Beispiel #3
0
        /// <summary>
        ///Update Office
        /// </summary>
        public Office  UpdateOffice(Office office)
        {
            _dbContext = new BeerTapDBContext();

            _dbContext.Entry(office).State = System.Data.Entity.EntityState.Modified;
            _dbContext.SaveChanges();
            return(office);
        }
Beispiel #4
0
        /// <summary>
        ///Remove a tap
        /// </summary>
        public void RemoveTap(int tapId)
        {
            _dbContext = new BeerTapDBContext();
            Tap tap = _dbContext.Taps.Where(o => o.Id == tapId).FirstOrDefault();

            _dbContext.Entry(tap).State = System.Data.Entity.EntityState.Deleted;
            _dbContext.SaveChanges();
        }
Beispiel #5
0
        /// <summary>
        ///Update Beer Tap
        /// </summary>
        public Tap UpdateTap(Tap tap)
        {
            _dbContext = new BeerTapDBContext();
            Tap t = _dbContext.Taps.Where(o => o.Id == tap.Id).Include("Keg").FirstOrDefault();

            t.Label    = tap.Label;
            t.OfficeId = tap.OfficeId;
            t.Keg      = tap.Keg;

            _dbContext.Entry(t).State = System.Data.Entity.EntityState.Modified;

            _dbContext.SaveChanges();
            return(tap);
        }