public RESERVATION Add(RESERVATION entity) { RESERVATION insertedReservation = null; if (CheckHelper.IsFilled(entity)) { using (ctx = new ReadingRoomsEntities()) { entity.RES_ID = 1; RESERVATION maxReservation = ctx.RESERVATIONs.OrderByDescending(s => s.RES_ID).FirstOrDefault(); if (CheckHelper.IsFilled(maxReservation)) { entity.RES_ID = maxReservation.RES_ID + 1; } if (CheckHelper.IsFilled(entity.SEATs)) { foreach (SEAT seat in entity.SEATs) { ctx.Entry(seat).State = EntityState.Unchanged; } } insertedReservation = ctx.RESERVATIONs.Add(entity); ctx.SaveChanges(); } } return(insertedReservation); }
public USER Update(USER entity) { USER updatedUser = null; using (ctx = new ReadingRoomsEntities()) { updatedUser = ctx.USERs.Attach(entity); ctx.Entry(entity).State = EntityState.Modified; ctx.SaveChanges(); } return(updatedUser); }
public READING_ROOM Update(READING_ROOM entity) { READING_ROOM updatedReadingRoom = null; using (ctx = new ReadingRoomsEntities()) { updatedReadingRoom = ctx.READING_ROOM.Attach(entity); ctx.Entry(entity).State = EntityState.Modified; ctx.SaveChanges(); } return(updatedReadingRoom); }
public SEAT Update(SEAT entity) { SEAT updatedSeat = null; using (ctx = new ReadingRoomsEntities()) { updatedSeat = ctx.SEATs.Attach(entity); ctx.Entry(entity).State = EntityState.Modified; ctx.SaveChanges(); } return(updatedSeat); }
public UNIVERSITY Update(UNIVERSITY entity) { UNIVERSITY updatedUni = null; using (ctx = new ReadingRoomsEntities()) { updatedUni = ctx.UNIVERSITies.Attach(entity); ctx.Entry(entity).State = EntityState.Modified; ctx.SaveChanges(); } return(updatedUni); }
public FACULTY Update(FACULTY entity) { FACULTY updatedFaculty = null; using (ctx = new ReadingRoomsEntities()) { updatedFaculty = ctx.FACULTies.Attach(entity); ctx.Entry(entity).State = EntityState.Modified; ctx.SaveChanges(); } return(updatedFaculty); }
public RESERVATION Update(RESERVATION entity) { RESERVATION updatedReservation = null; using (ctx = new ReadingRoomsEntities()) { updatedReservation = ctx.RESERVATIONs.Attach(entity); ctx.Entry(entity).State = EntityState.Modified; ctx.SaveChanges(); } return(updatedReservation); }