Ejemplo n.º 1
0
        public void RemoveDogFromRoom(DogInRoomDetailsView dog, int RoomNumber)
        {
            try
            {
                using (Entities context = new Entities())
                {
                    //context.Blogs
                    //.Where(b => b.Name == "ADO.NET Blog")
                    //.FirstOrDefault();
                    var dogt = context.RoomSetting.Where(d => d.RoomNumber == RoomNumber && d.DogNumber == dog.DogNumber && d.OrderNumber == dog.OrderNumber).First();
                    dog.RoomShiftTo  = (int)dogt.RoomShiftTo;
                    dog.ToDateInRoom = (DateTime)dogt.RoomToDate;

                    if (dogt != null)
                    {
                        if (dog.RoomShiftFrom == 1)   //אם הוצאתי כלב במשמרת בוקר, הוא היה בחדר הקודם עד אתמול במשמרת ערב
                        {
                            dogt.RoomToDate  = dog.FromDateInRoom.AddDays(-1);
                            dogt.RoomShiftTo = 2;
                        }
                        else //RoomShiftFrom==2   //אם הוצאתי כלב במשמרת ערב, הוא היה בחדר הקודם עד היום במשמרת בוקר
                        {
                            dogt.RoomToDate  = dog.FromDateInRoom;
                            dogt.RoomShiftTo = 1;
                        }

                        //  context.Entry(dogt).CurrentValues.SetValues(dog);
                        //   context.Entry(dogt).State = EntityState.Deleted;
                        context.SaveChanges();
                    }
                    else
                    {
                        throw new Exception();
                    }

                    context.Dispose();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public void AddDogToRoom(DogInRoomDetailsView dog, int roomNumber)
        {
            try
            {
                Entities    context     = new Entities();
                RoomSetting roomSetting = new RoomSetting();
                roomSetting.Comments      = dog.Comments;
                roomSetting.DogNumber     = dog.DogNumber;
                roomSetting.RoomNumber    = roomNumber;
                roomSetting.OrderNumber   = dog.OrderNumber;
                roomSetting.RoomFromDate  = dog.FromDateInRoom;
                roomSetting.RoomToDate    = dog.ToDateInPension;
                roomSetting.RoomShiftFrom = dog.RoomShiftFrom;
                roomSetting.RoomShiftTo   = dog.RoomShiftTo;
                context.RoomSetting.Add(roomSetting);
                context.SaveChanges();
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        //כל הכלבים בכל ההזמנות בתאריך והמשמרת המבוקשים
        public List <DogInRoomDetailsView> GetDogsNoSetting(DateTime date, int shift)

        {
            List <DogInRoomDetailsView> dogsInRoom = new List <DogInRoomDetailsView>();

            using (Entities context = new Entities())
            {
                int rooms = context.RoomsTbl.Count();
                //כל הכלבים המשובצים לחדרים בתאריכים המבןקשים

                for (int i = 1; i <= rooms; i++)
                {
                    dogsInRoom.AddRange(GetDogsInRoom(i, date, shift));
                }

                OrderService orderService = new OrderService();
                //כל ההזמנות
                List <OrderDetailsViewManager> listOrders = orderService.GetAllOrdersAndDogsManager();
                // כל ההזמנות בתאריך והמשמרת המבוקשים
                List <OrderDetailsViewManager> listOrderInDates = listOrders.Where(
                    p => (p.OrderStatus == 12 || p.OrderStatus == 15) &&
                    (p.FromDate <date && p.ToDate> date) ||
                    (p.FromDate == date && p.ShiftNumberFrom <= shift) ||
                    (p.ToDate == date && p.ShiftNumberTo >= shift)

                    ).ToList();
                List <DogsInOrderView> dogsInOrders = new List <DogsInOrderView>();
                //כל הכלבים בכל ההזמנות בתאריך והמשמרת המבוקשים
                for (int i = 0; i < listOrderInDates.Count; i++)
                {
                    dogsInOrders.AddRange(orderService.GetDogsForOrder(listOrderInDates[i].OrderNumber));
                }

                List <DogInRoomDetailsView> outOfRoomsList = new List <DogInRoomDetailsView>();
                foreach (DogsInOrderView dogInOrder in dogsInOrders)
                {
                    if (isExist(dogInOrder.DogNumber, dogsInRoom) == -1)     //כלב בהזמנה ולא משובץ בחדר
                    {
                        DogInRoomDetailsView dogOutOfRoom = new DogInRoomDetailsView();
                        dogOutOfRoom.DogComments  = dogInOrder.DogComments;
                        dogOutOfRoom.DogBirthDate = dogInOrder.DogBirthDate;
                        dogOutOfRoom.DogDig       = dogInOrder.DogDig;
                        // dogOutOfRoom.DogFood=dogInOrder.
                        dogOutOfRoom.DogFriendlyWith  = dogInOrder.DogFriendlyWith;
                        dogOutOfRoom.DogGender        = dogInOrder.DogGender;
                        dogOutOfRoom.DogImage         = dogInOrder.DogImage;
                        dogOutOfRoom.DogJump          = dogInOrder.DogJump;
                        dogOutOfRoom.DogName          = dogInOrder.DogName;
                        dogOutOfRoom.DogNeuter        = dogInOrder.DogNeuter;
                        dogOutOfRoom.DogNumber        = dogInOrder.DogNumber;
                        dogOutOfRoom.DogorderNumber   = dogInOrder.OrderNumber;
                        dogOutOfRoom.DogRabiesVaccine = dogInOrder.DogRabiesVaccine;
                        dogOutOfRoom.DogShvav         = dogInOrder.DogShvav;
                        dogOutOfRoom.DogStatus        = dogInOrder.DogStatus;
                        dogOutOfRoom.DogTraining      = dogInOrder.DogTraining;
                        dogOutOfRoom.DogType          = dogInOrder.DogType;
                        dogOutOfRoom.DogUserID        = dogInOrder.DogUserID;
                        dogOutOfRoom.OrderNumber      = dogInOrder.OrderNumber;

                        OrderDetailsViewManager orderDetailsViewManager = listOrderInDates.Find(o => o.OrderNumber == dogOutOfRoom.OrderNumber);
                        dogOutOfRoom.DogUserID         = orderDetailsViewManager.Userid;
                        dogOutOfRoom.FromDateInPension = orderDetailsViewManager.FromDate;
                        dogOutOfRoom.ToDateInPension   = orderDetailsViewManager.ToDate;
                        dogOutOfRoom.ToDateInRoom      = orderDetailsViewManager.ToDate;
                        dogOutOfRoom.RoomShiftTo       = orderDetailsViewManager.ShiftNumberTo;
                        dogOutOfRoom.UserFirstName     = orderDetailsViewManager.userFirstName;
                        dogOutOfRoom.UserLastName      = orderDetailsViewManager.userLastName;
                        var user = context.UsersTbl.Find(dogOutOfRoom.DogUserID);
                        dogOutOfRoom.UserPhone1 = user.UserPhone1;
                        dogOutOfRoom.UserPhone2 = user.UserPhone2;
                        var vet = context.veterinarTbl.Find(user.UserVeterinarId);
                        dogOutOfRoom.VeterinarName   = vet.VeterinarName;
                        dogOutOfRoom.VeterinarPhone1 = vet.VeterinarPhone1;
                        dogOutOfRoom.RoomNumberDB    = 0;
                        outOfRoomsList.Add(dogOutOfRoom);
                    }
                }
                return(outOfRoomsList);
            }
        }