public int Save(TEntity entity) { PropertyInfo property = entity.GetType().GetProperty("CreatedBy"); property.SetValue(entity, HttpContext.Current.Session["User"], null); property = entity.GetType().GetProperty("CreatedOn"); property.SetValue(entity, DateTime.Now, null); OBTMDbSet.Add(entity); OBTMDbContext.SaveChanges(); return(OBTMDbContext.SaveChanges()); }
public int SaveEditedBus(BusOperator bus) { var b = OBTMDbContext.BusOperators.Where(i => i.Id == bus.Id).Single(); b.Name = bus.Name; b.Email = bus.Email; OBTMDbContext.Entry(b).State = EntityState.Modified; return(OBTMDbContext.SaveChanges()); }
public int DeleteSoft(object id) { var obj = OBTMDbSet.Find(id); obj.IsDeleted = true; OBTMDbContext.Entry(obj).State = System.Data.Entity.EntityState.Modified; return(OBTMDbContext.SaveChanges()); }
public int DeleteBusSoft(int id) { var obj = OBTMDbContext.BusOperators.Find(id); obj.IsDeleted = true; OBTMDbContext.Entry(obj).State = EntityState.Modified; return(OBTMDbContext.SaveChanges()); }
public int DeleteSingleRouteForBus(int id) { var obj = OBTMDbContext.OperatorRouteMaps.Where(opId => opId.Id == id).ToList(); foreach (var item in obj) { item.IsDeleted = true; OBTMDbContext.Entry(item).State = EntityState.Modified; } return(OBTMDbContext.SaveChanges()); }
public int DeleteOperatorRouteSoft(int id) { var obj = OBTMDbContext.OperatorRouteMaps.Where(bus => bus.BusOperatorId == id).ToList(); foreach (var item in obj) { item.IsDeleted = true; OBTMDbContext.Entry(item).State = EntityState.Modified; } return(OBTMDbContext.SaveChanges()); }
public int SoftDelete(int id) { DateWiseTrip dateWiseTrip = OBTMDbContext.DateWiseTrips.Find(id); bool isAnySeatPurchased = OBTMDbContext.BookingTickets.Where(bt => bt.DateWiseTripId == dateWiseTrip.Id && bt.IsBooked == true).Any(); if (isAnySeatPurchased) { return(-1); } else { dateWiseTrip.IsDeleted = true; OBTMDbContext.Entry(dateWiseTrip).State = EntityState.Modified; return(OBTMDbContext.SaveChanges()); } }