コード例 #1
0
        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());
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        public int DeleteBusSoft(int id)
        {
            var obj = OBTMDbContext.BusOperators.Find(id);

            obj.IsDeleted = true;
            OBTMDbContext.Entry(obj).State = EntityState.Modified;


            return(OBTMDbContext.SaveChanges());
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        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());
            }
        }