Example #1
0
        public static List <Aisle> LoadByLayoutId(Guid layoutId)
        {
            try
            {
                List <Aisle> aisles = new List <Aisle>();
                using (GroceryGetterEntities dc = new GroceryGetterEntities())
                {
                    var results = dc.tblAisles.Where(a => a.LayoutId == layoutId);

                    foreach (var aisle in results)
                    {
                        Aisle a = new Aisle();
                        a.Id       = aisle.Id;
                        a.LayoutId = aisle.LayoutId;
                        a.Number   = aisle.Number;
                        a.Lineup   = aisle.Lineup;
                        a.Products = ProductManager.LoadByAisleId(aisle.Id);
                        aisles.Add(a);
                    }
                }
                return(aisles);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        private void CreateAisle(string v)
        {
            Aisle aisle = View.ObjectSpace.CreateObject <Aisle>();

            aisle.Name = v;
            aisle.Save();
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, [Bind("AisleID,StoreID,AisleNumber,CategoryID")] Aisle aisle)
        {
            if (id != aisle.AisleID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(aisle);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AisleExists(aisle.AisleID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(aisle));
        }
Example #4
0
        public void MoveBookAlreadyInThatShelf()
        {
            var currentAisle = new Aisle {
                AisleNumber = 1
            };
            var currentShelf = (new Shelf
            {
                ShelfNumber = 1,
                Aisle = currentAisle
            });

            var shelfManagerMock = SetupMock(currentShelf);

            var bookManagerMock = SetupMock(new Book
            {
                BookID = 1,
                Shelf  = currentShelf
            });

            var bookAPI = new BookAPI(shelfManagerMock.Object, bookManagerMock.Object);
            var result  = bookAPI.MoveBook("Circe", 1, 1);

            Assert.AreEqual(MoveBookStatusCodes.BookAlreadyInThatShelf, result);
            bookManagerMock.Verify(m =>
                                   m.MoveBook(1, 1), Times.Never());
        }
Example #5
0
        public void DeleteTest()
        {
            List <Aisle> aisles = AisleManager.Load();
            Aisle        aisle  = aisles.Where(a => a.Number == "New Aisle").FirstOrDefault();
            int          actual = AisleManager.Delete(aisle);

            Assert.IsTrue(actual > 0);
        }
Example #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Aisle aisle = db.Aisles.Find(id);

            db.Aisles.Remove(aisle);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #7
0
 public static AisleDTO From(Aisle aisle)
 {
     var dto = new AisleDTO();
     dto.Name = aisle.Name;
     dto.Rows = aisle.Rows;
     dto.Columns = aisle.Columns;
     return dto;
 }
Example #8
0
        public void AddAisle(int aisleNumber)
        {
            using var libraryContext = new LibraryContext();
            var aisle = new Aisle();

            aisle.AisleNumber = aisleNumber;
            libraryContext.Aisles.Add(aisle);
            libraryContext.SaveChanges();
        }
Example #9
0
 public void AddAisle(int aisleNr)
 {
     using (var LibraryContext = new LibraryContext())
     {
         var aisle = new Aisle();
         aisle.AisleNr = aisleNr;
         LibraryContext.Aisle.Add(aisle);
         LibraryContext.SaveChanges();
     }
 }
Example #10
0
 public ActionResult Edit([Bind(Include = "Id,Name")] Aisle aisle)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aisle).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(aisle));
 }
Example #11
0
        public VariusTest()
        {
            using (ExampleContext exampleContext = new ExampleContext())
            {
                // Populate Silo Warehouse
                Island silo = new Island();
                silo.Name = "Silo";

                exampleContext.Positions.Add(silo);

                // Populate Picking Warehouse
                Island picking = new Island();
                picking.Name = "Picking";

                exampleContext.Positions.Add(picking);

                exampleContext.SaveChanges();

                // Populate aisles
                Dictionary <int, Aisle> aisles = new Dictionary <int, Aisle>();
                for (int i = 1; i <= 5; i++)
                {
                    Aisle aisle = new Aisle();
                    aisle.AisleNumber    = i;
                    aisle.Name           = "Pasillo " + i;
                    aisle.ParentPosition = silo;
                    aisles.Add(i, aisle);

                    exampleContext.Positions.Add(aisle);
                }

                exampleContext.SaveChanges();

                // Populate silo location
                for (int i = 1; i <= 5; i++)
                {
                    for (int j = 1; j <= 5; j++)
                    {
                        for (int k = 1; k <= 5; k++)
                        {
                            SiloLocation siloLocation = new SiloLocation();
                            siloLocation.CoordX         = i;
                            siloLocation.CoordY         = j;
                            siloLocation.CoordP         = k;
                            siloLocation.Name           = "S" + i + j + k;
                            siloLocation.ParentPosition = aisles[i];

                            exampleContext.Positions.Add(siloLocation);
                        }
                    }
                }

                exampleContext.SaveChanges();
            }
        }
Example #12
0
        public async Task <IActionResult> AddAisle(Aisle aisle)
        {
            var client = _clientFactory.CreateClient();

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var aisleJsonString = JsonConvert.SerializeObject(aisle);
            var stringContent   = new StringContent(aisleJsonString, Encoding.UTF8, "application/json");
            var result          = await client.PostAsync("https://localhost:44349/aisle", stringContent);

            return(View("Index"));
        }
Example #13
0
 public Aisle AddAisle(int aisleNumber)
 {
     using (var libraryContext = new LibraryContext())
     {
         Aisle aisle = new Aisle();
         aisle.AisleNumber = aisleNumber;
         libraryContext.Aisles.Add(aisle);
         libraryContext.SaveChanges();
         return(aisle);
     }
 }
Example #14
0
        public void InsertTest()
        {
            List <Layout> layouts = new List <Layout>();
            Layout        layout  = layouts.Where(l => l.Title == "L_Aldi-De Pere").FirstOrDefault();
            Aisle         aisle   = new Aisle {
                LayoutId = layout.Id, Number = "Test Aisle", Lineup = 999999
            };
            int actual = AisleManager.Insert(aisle);

            Assert.IsTrue(actual > 0);
        }
Example #15
0
        public ActionResult Create([Bind(Include = "Id,Name")] Aisle aisle)
        {
            if (ModelState.IsValid)
            {
                db.Aisles.Add(aisle);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aisle));
        }
Example #16
0
        public async Task <IActionResult> Create([Bind("AisleID,StoreID,AisleNumber,CategoryID")] Aisle aisle)
        {
            if (ModelState.IsValid)
            {
                _context.Add(aisle);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(aisle));
        }
Example #17
0
        private static Mock <IAisleManager> SetupMock(Aisle aisle)
        {
            var aislemanagerMock = new Mock <IAisleManager>();

            aislemanagerMock.Setup(m =>
                                   m.GetAisleByNumber(It.IsAny <int>()))
            .Returns(aisle);

            aislemanagerMock.Setup(m =>
                                   m.AddAisle(It.IsAny <int>()));
            return(aislemanagerMock);
        }
Example #18
0
 public ActionResult Create(Aisle aisle)
 {
     try
     {
         // TODO: Add insert logic here
         AisleManager.Insert(aisle);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(aisle));
     }
 }
Example #19
0
 public ActionResult Edit([Bind(Include = "Number, Lineup")] Aisle aisle, Guid LayoutId)
 {
     try
     {
         // TODO: Add update logic here
         AisleManager.Update(aisle);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(aisle));
     }
 }
        private void LogX_TarhelyGeneralas_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            numberOfAisle  = 2;
            numberOfColumn = 50;
            numberOFRow    = 10;
            abcType        = View.ObjectSpace.FindObject <AbcType>(new BinaryOperator("Code", "A"));
            LcT            = View.ObjectSpace.FindObject <LoadCarrierType>(new BinaryOperator("Name", "MAGAS"));


            for (int i = 0; i < numberOfAisle; i++)
            {
                CriteriaOperator criteria = CriteriaOperator.Parse("Oid = ?", i + 1);
                Aisle            aisle    = View.ObjectSpace.FindObject <Aisle>(criteria);

                for (int j = 0; j < numberOfLine; j++)
                {
                    tomb++;

                    for (int k = 0; k < numberOfColumn; k++)
                    {
                        for (int l = 0; l < numberOFRow; l++)
                        {
                            //Láda létrehozása
                            loadCarriers = View.ObjectSpace.CreateObject <LoadCarrier>();
                            barCode++;
                            loadCarriers.BarCode = barCode;
                            loadCarriers.RFID1   = Convert.ToString(1000 + barCode);
                            loadCarriers.RFID2   = Convert.ToString(2000 + barCode);
                            loadCarriers.LcType  = LcT;

                            //Tárolóhely létrehozása
                            storageLocation             = View.ObjectSpace.CreateObject <StorageLocation>();
                            storageLocation.Aisle       = aisle;
                            storageLocation.Block       = tomb;
                            storageLocation.Column      = Convert.ToUInt16(k + 1);
                            storageLocation.Row         = Convert.ToByte(l + 1);
                            storageLocation.Name        = storageLocation.Aisle.Name + "_" + storageLocation.Block + "_" + storageLocation.Column + "_" + storageLocation.Row;
                            storageLocation.AbcClass    = abcType;;
                            storageLocation.LHU1X       = 10;
                            storageLocation.LHU1Y       = 10;
                            storageLocation.LHU2X       = 10;
                            storageLocation.LHU2Y       = 10;
                            storageLocation.LoadCarrier = loadCarriers;
                            storageLocation.LcIsEmpty   = true;
                        }
                    }
                }
            }
            //View.ObjectSpace.CommitChanges();
            MessageBox.Show("Finished!" + ciklus.ToString());
        }
Example #21
0
        //#region Státuszok beolvasása  / Status
        //private void Import_Status()
        //{
        //    var fileContent = string.Empty;
        //    var filePath = string.Empty;
        //    int rekord = 0;

        //    using (var fileStream = new FileStream(@"C:\Projects\LogXExplorer\Imports\LogX_Status.csv", FileMode.Open, FileAccess.Read))
        //    {

        //            StreamReader reader = new StreamReader(fileStream);

        //            while (!reader.EndOfStream)
        //            {
        //                string line = reader.ReadLine();
        //                var values = line.Split(';');

        //                if (rekord > 0)
        //                {
        //                    CriteriaOperator criteria = CriteriaOperator.Parse("Code", values[0]);
        //                    Status existedStatus = (Status)View.ObjectSpace.FindObject(typeof(Status), criteria, true);

        //                    if (values[0] != "")
        //                    {
        //                        Status status = View.ObjectSpace.CreateObject<Status>();
        //                        status.Code = values[0];
        //                        status.Name = values[1];

        //                        status.Save();
        //                    }

        //                }
        //                rekord++;
        //            }
        //            View.ObjectSpace.CommitChanges();

        //    }
        //}

        //#endregion

        #region Tárhelyek beolvasása / StorageLocation

        private void Import_StorageLocation()
        {
            int rekord = 0;

            using (var fileStream = new FileStream(@"C:\Projects\LogXExplorer\Imports\LogX_StorageLocation.csv", FileMode.Open, FileAccess.Read))
            {
                StreamReader reader = new StreamReader(fileStream);

                while (!reader.EndOfStream)
                {
                    string line   = reader.ReadLine();
                    var    values = line.Split(';');

                    if (rekord > 0)
                    {
                        CriteriaOperator criteriaAisle = new BinaryOperator("Name", values[0]);
                        Aisle            aisle         = (Aisle)View.ObjectSpace.FindObject(typeof(Aisle), criteriaAisle, true);

                        if (aisle == null)
                        {
                            CreateAisle(values[0]);
                        }

                        CriteriaOperator criteriaAbc = new BinaryOperator("Code", values[5]);
                        AbcType          abc         = (AbcType)View.ObjectSpace.FindObject(typeof(AbcType), criteriaAbc, true);

                        if (values[0] != "")
                        {
                            StorageLocation storage = View.ObjectSpace.CreateObject <StorageLocation>();
                            storage.Aisle      = aisle;
                            storage.Block      = Convert.ToByte(values[1]);
                            storage.Column     = Convert.ToInt32(values[2]);
                            storage.Row        = Convert.ToByte(values[3]);
                            storage.Name       = values[4];
                            storage.AbcClass   = abc;
                            storage.LHU1X      = Convert.ToInt32(values[6]);
                            storage.LHU1Y      = Convert.ToInt32(values[7]);
                            storage.LHU2X      = Convert.ToInt32(values[8]);
                            storage.LHU2Y      = Convert.ToInt32(values[9]);
                            storage.Height     = Convert.ToInt32(values[10]);
                            storage.StatusCode = 0;

                            storage.Save();
                        }
                    }
                    rekord++;
                }
                View.ObjectSpace.CommitChanges();
            }
        }
Example #22
0
        // GET: Aisles/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Aisle aisle = db.Aisles.Find(id);

            if (aisle == null)
            {
                return(HttpNotFound());
            }
            return(View(aisle));
        }
Example #23
0
        public Aisle AddAisle(Aisle aisle)
        {
            // add to database

            using (var storeContext = new StoreContext())
            {
                var aisles = storeContext.Aisles;
                aisles.Add(aisle);
                storeContext.SaveChanges();
            }

            // end add to database

            return(aisle);
        }
        /* Láda visszaküldés esetén üres tárolóhelyet keresünk (StatusCode = 0), adott folyosón, adott ládaméretben, adott abc kategóriának megfelelően.
         * Ha üres ládát küldünk vissza, akkor azABC besorolás nem számít.
         * A függvény adott paraméterekkel 1 rekordot ad vissza.
         */
        private StorageLocation AdottTarolohelykeresesFolyoson(int height, Aisle aisle, string abcTypeCode, int statusCode)
        {
            StorageLocation ret = null;
            IQueryable <StorageLocation> locations = serverObjectSpace.GetObjectsQuery <StorageLocation>();
            var list = (from c in locations
                        where (c.StatusCode == statusCode && c.Aisle == aisle && c.Height == height && (c.AbcClass.Code == abcTypeCode || abcTypeCode == null))
                        orderby c.Column, c.Row, c.Block ascending
                        select c).Take(1);

            foreach (StorageLocation item in list)
            {
                ret = item;
            }
            return(ret);
        }
Example #25
0
        //ADD BOOK:
        private AddBookStatusCodes AddFirstBookCirce(Mock <IBookManager> bookManagerMock)
        {
            var aisle = new Aisle {
                AisleNumber = 3
            };
            var shelfManagerMock = SetupMock(new Shelf
            {
                ShelfNumber = 1,
                Aisle       = aisle
            });

            var bookAPI     = new BookAPI(shelfManagerMock.Object, bookManagerMock.Object);
            var successfull = bookAPI.AddBook("9781526610140", "Circe", "Madeline Miller", 199, 4, 1, 3);

            return(successfull);
        }
Example #26
0
        public static int Insert(Aisle aisle)
        {
            using (GroceryGetterEntities dc = new GroceryGetterEntities())
            {
                tblAisle tblaisle = new tblAisle();
                tblaisle.Id       = Guid.NewGuid();
                tblaisle.LayoutId = aisle.LayoutId;
                tblaisle.Number   = aisle.Number;
                tblaisle.Lineup   = aisle.Lineup;

                aisle.Id = tblaisle.Id;

                dc.tblAisles.Add(tblaisle);
                return(dc.SaveChanges());
            }
        }
Example #27
0
        public void TestSiloLocation()
        {
            using (ExampleContext exampleContext = new ExampleContext())
            {
                // Silo location total assert
                IQueryable <SiloLocation> siloLocations = exampleContext.Positions.OfType <SiloLocation>();
                Assert.AreEqual(125, siloLocations.Count());

                // Aisle total assert
                IQueryable <Aisle> aisles = exampleContext.Positions.OfType <Aisle>();
                Assert.AreEqual(5, aisles.Count());

                // Get Aisle location
                Aisle aisle = exampleContext.Positions.OfType <Aisle>().FirstOrDefault(a => a.AisleNumber == 1);
                Assert.IsNotNull(aisle);

                // Get all locations in asile
                exampleContext.Entry(aisle).Collection(a => a.ChildPositions).Load();
                Assert.AreEqual(25, aisle.ChildPositions.Count);

                //Get silo location
                SiloLocation siloLocation = exampleContext.Positions.OfType <SiloLocation>().FirstOrDefault(s => s.CoordX == 1 && s.CoordY == 1 && s.CoordP == 1);
                Assert.IsNotNull(siloLocation);

                // Get aisle of location
                exampleContext.Entry(siloLocation).Reference(s => s.ParentPosition).Load();
                Assert.IsTrue(siloLocation.ParentPosition is Aisle);
                Assert.AreEqual(1, ((Aisle)siloLocation.ParentPosition).AisleNumber);

                // Get Warehouse of location I
                Aisle aisle2 = (Aisle)siloLocation.ParentPosition;
                exampleContext.Entry(aisle2).Reference(a => a.ParentPosition).Load();
                Assert.AreEqual("Silo", aisle2.ParentPosition.Name);

                // Get Warehouse of location II
                SiloLocation siloLocation2 = exampleContext.Positions.OfType <SiloLocation>().Include(s => s.ParentPosition.ParentPosition).FirstOrDefault(s => s.CoordX == 1 && s.CoordY == 1 && s.CoordP == 1);
                Assert.IsNotNull(siloLocation2);
                Assert.AreEqual("Silo", siloLocation2.ParentPosition.ParentPosition.Name);

                // Get all location of warehouse
                var silolocations = exampleContext.Positions.Where(p => p.ParentPosition.ParentPosition.Name == "Silo");
                Assert.AreEqual(125, silolocations.Count());
            }
        }
Example #28
0
        public void MoveShelfAlreadyInThatAisle()
        {
            var currentAisle = new Aisle {
                AisleNumber = 2
            };
            var aisleManagerMock = SetupMock(currentAisle);
            var shelfManagerMock = SetupMock(new Shelf
            {
                ShelfID = 2,
                Aisle   = currentAisle
            });

            var storageAPI = new StorageAPI(aisleManagerMock.Object, shelfManagerMock.Object);
            var result     = storageAPI.MoveShelf(2, 2);

            Assert.AreEqual(MoveShelfStatusCodes.ShelfAlreadyInThatAisle, result);
            shelfManagerMock.Verify(m =>
                                    m.MoveShelf(2, 2), Times.Never());
        }
Example #29
0
        public static int Update(Aisle aisle)
        {
            using (GroceryGetterEntities dc = new GroceryGetterEntities())
            {
                tblAisle tblaisle = dc.tblAisles.FirstOrDefault(a => a.Id == aisle.Id);

                if (tblaisle != null)
                {
                    tblaisle.LayoutId = aisle.LayoutId;
                    tblaisle.Number   = aisle.Number;
                    tblaisle.Lineup   = aisle.Lineup;

                    return(dc.SaveChanges());
                }
                else
                {
                    return(0);
                }
            }
        }
Example #30
0
        public void TestAddBookOk()
        {
            var bookManagerMock = new Mock <IBookManager>();
            var aisle           = new Aisle {
                AisleNumber = 3
            };
            var shelfManagerMock = SetupMock(new Shelf
            {
                ShelfNumber = 1,
                Aisle       = aisle
            });

            var successfull = AddFirstBookCirce(bookManagerMock);

            Assert.AreEqual(AddBookStatusCodes.Ok, successfull);
            bookManagerMock.Verify(
                m => m.AddBook(It.Is <string>(i => i == "9781526610140"), It.Is <string>(i => i == "Circe"), It.Is <string>(i => i == "Madeline Miller"),
                               It.Is <int>(i => i == 2019), It.Is <int>(i => i == 199), It.Is <int>(i => i == 4), It.IsAny <Shelf>(),
                               It.Is <bool>(i => i == false), It.Is <Borrow>(i => i == null)),
                Times.Once());
        }
Example #31
0
        public static int Delete(Aisle aisle)
        {
            try
            {
                using (GroceryGetterEntities dc = new GroceryGetterEntities())
                {
                    tblAisle tblaisle = dc.tblAisles.FirstOrDefault(a => a.Id == aisle.Id);

                    if (tblaisle != null)
                    {
                        dc.tblAisles.Remove(tblaisle);
                        return(dc.SaveChanges());
                    }
                    else
                    {
                        return(0);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #32
0
 public void AddAisle(Aisle aisle)
 {
     Aisles.Add(aisle);
 }