Ejemplo n.º 1
0
        //Get all the occupied stand

        //var filter = Builders<Occupied>.Filter;
        //var SearchFilter = filter.Lte(d => d.CheckIn, Stand.CheckIn) &
        //    filter.Gt(d => d.CheckOut, Stand.CheckIn) &
        //    filter.Eq(oc => oc.StandType, Stand.StandType) & filter.Eq(oc => oc.WorkSpaceID, Stand.WorkSpaceID);
        //var collection = GetOccupiedCollection().Find(SearchFilter).ToList();

        public static IEnumerable <Occupied> GetOccuipedInPeriod(ReservedStand Stand)
        {
            //insertStandToOccupiedList(Stand);

            var filter       = Builders <Occupied> .Filter;
            var SearchFilter = ((filter.Gte(d => d.CheckIn, Stand.CheckIn) &
                                 filter.Lt(d => d.CheckIn, Stand.CheckOut)) | (filter.Gte(d => d.CheckOut, Stand.CheckIn))) &
                               filter.Eq(oc => oc.StandType, Stand.StandType) & filter.Eq(oc => oc.WorkSpaceID, Stand.WorkSpaceID);

            var collection = GetOccupiedCollection().Find(SearchFilter).ToList();

            return(collection);
            //אני רוצה את כל הסטנדים שהתאריך המבוקש לא נופל בין התאריכים המבוקשים ומאחר את זה עם סטנד ליסט של אותו חלל עבודה
        }
Ejemplo n.º 2
0
        public HttpResponseMessage CheckAvilability(ReservedStand R_Stand)
        {
            R_Stand.CheckIn  = R_Stand.CheckIn.AddDays(1);
            R_Stand.CheckOut = R_Stand.CheckOut.AddDays(1);
            HttpResponseMessage    response;
            IEnumerable <Occupied> Occuiped        = DB.DBManager.GetOccuipedInPeriod(R_Stand).ToList(); //Return all the occuiped stand for the stand type & workspace user has select
            IEnumerable <Stand>    AvailableStands = DB.DBManager.CheckIfStandAvailable(Occuiped, R_Stand);

            if (AvailableStands.Count() > 0)
            {
                ReservedStand reserved = Convert_StandToReservedStand(AvailableStands.FirstOrDefault(), R_Stand);
                return(response = Request.CreateResponse(HttpStatusCode.OK, reserved));
            }
            return(response = Request.CreateResponse(HttpStatusCode.Conflict, "We couldn't found any avialable stand for this dates"));
        }
Ejemplo n.º 3
0
 //Convert ReservedStand object to Occuiped obj in order to set the stand to be occuiped in the date that as given in each order item.
 public static Occupied Convert_ReservedStandToOccupied(ReservedStand RS, ObjectId OrderId)
 {
     if (RS != null)
     {
         Occupied item = new Occupied()
         {
             OrderID     = OrderId.ToString(),
             CheckIn     = RS.CheckIn,
             CheckOut    = RS.CheckOut,
             StandID     = RS.StandID,
             StandType   = RS.StandType,
             WorkSpaceID = RS.WorkSpaceID
         };
         return(item);
     }
     return(null);
 }
Ejemplo n.º 4
0
 //Convert Stand object to ReservedStand obj
 private ReservedStand Convert_StandToReservedStand(Stand stand, ReservedStand R_Stand)
 {
     if (stand != null && R_Stand != null)
     {
         ReservedStand reserved = new ReservedStand()
         {
             Stand       = stand,
             StandID     = stand.ID.ToString(),
             StandType   = stand.Type,
             CheckIn     = R_Stand.CheckIn,
             CheckOut    = R_Stand.CheckOut,
             PeriodPrice = R_Stand.PeriodPrice,
             WorkSpaceID = stand.WorkSpaceID.ToString(),
         };
         return(reserved);
     }
     return(null);
 }
Ejemplo n.º 5
0
        public List <Order> SampleOrderList()
        {
            Stand s1 = new Stand()
            {
                Size        = 100,
                MonthlyRate = 220.0,
                DailyRate   = 80,
                Quantity    = 11,
            };
            ReservedStand item1 = new ReservedStand()
            {
                StandID  = "12344",
                Stand    = s1,
                CheckIn  = new DateTime(),
                CheckOut = new DateTime()
            };
            User user1 = new User()
            {
                FirstName = "david",
                Email     = "*****@*****.**"
            };
            ObjectId             Id     = new ObjectId();
            ObjectId             compId = new ObjectId();
            DateTime             start  = new DateTime().Date;
            DateTime             end    = new DateTime().Date;
            List <ReservedStand> st     = new List <ReservedStand>();

            st.Add(item1);
            Order order = new Order()
            {
                ID            = Id,
                StandsInOrder = st,
                CompanyID     = compId.ToString(),
                TotalPrice    = 1000,
                User          = user1
            };
            List <Order> orderList = new List <Order>();

            orderList.Add(order);
            return(orderList);
        }
Ejemplo n.º 6
0
        public static IEnumerable <Stand> CheckIfStandAvailable(IEnumerable <Occupied> occupiedStand, ReservedStand R_Stand)
        {
            ObjectId WS_ID           = new ObjectId(R_Stand.WorkSpaceID);
            var      WorkspaceStands = GetWorkSpaceStandsByType(WS_ID, R_Stand.StandType);
            //This query take all the exsiting stand (*By Type) in the given workspace and remove from it the occuiped stand
            var query = from std in WorkspaceStands.AsQueryable()
                        join ocd in occupiedStand.AsQueryable() on std.ID.ToString() equals ocd.StandID into AvialableStands
                            where !AvialableStands.Any()
                        select new Stand
            {
                ID          = std.ID,
                WS_ID       = std.WS_ID,
                DailyRate   = std.DailyRate,
                MonthlyRate = std.MonthlyRate,
                Type        = std.Type
            };
            IEnumerable <Stand> Avialable = query.ToList();

            return(Avialable);
        }
Ejemplo n.º 7
0
        //Get from the occupied collection all matchs result (stand) as a list.
        //when user want to place an order we will get list from the occupied collection in order to check date avilability inside the occupetion list
        public static IEnumerable <Occupied> GetOccupiedStandsByType(ReservedStand Stand)
        {
            var collection = GetOccupiedCollection().Find(rs => rs.StandType == Stand.StandType && rs.WorkSpaceID == Stand.WorkSpaceID).ToList();

            return(collection);
        }