public UNIVERSITY Add(UNIVERSITY entity) { UNIVERSITY insertedUni = null; if (CheckHelper.IsFilled(entity)) { using (ctx = new ReadingRoomsEntities()) { entity.UNI_ID = 1; UNIVERSITY maxUni = ctx.UNIVERSITies.OrderByDescending(u => u.UNI_ID).FirstOrDefault(); if (CheckHelper.IsFilled(maxUni)) { entity.UNI_ID = maxUni.UNI_ID + 1; } insertedUni = ctx.UNIVERSITies.Add(entity); ctx.SaveChanges(); } } return(insertedUni); }
public SEAT Add(SEAT entity) { SEAT insertedSeat = null; if (CheckHelper.IsFilled(entity)) { using (ctx = new ReadingRoomsEntities()) { entity.SEAT_ID = 1; SEAT maxSeat = ctx.SEATs.OrderByDescending(s => s.SEAT_ID).FirstOrDefault(); if (CheckHelper.IsFilled(maxSeat)) { entity.SEAT_ID = maxSeat.SEAT_ID + 1; } insertedSeat = ctx.SEATs.Add(entity); ctx.SaveChanges(); } } return(insertedSeat); }
public FACULTY Add(FACULTY entity) { FACULTY insertedFaculty = null; if (CheckHelper.IsFilled(entity)) { using (ctx = new ReadingRoomsEntities()) { entity.FAC_ID = 1; FACULTY maxFaculty = ctx.FACULTies.OrderByDescending(f => f.FAC_ID).FirstOrDefault(); if (CheckHelper.IsFilled(maxFaculty)) { entity.FAC_ID = maxFaculty.FAC_ID + 1; } insertedFaculty = ctx.FACULTies.Add(entity); ctx.SaveChanges(); } } return(insertedFaculty); }