Example #1
0
        public async Task <IHttpActionResult> PostInventory(InventoryVM inventoryVM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var inventory = new Inventory()
            {
                Id          = Guid.NewGuid(),
                Name        = inventoryVM.Name,
                Price       = inventoryVM.Price,
                CreatedBy   = inventoryVM.CreatedBy,
                CreatedDate = DateTime.Now,
            };

            try
            {
                await this._repo.CreateInventory(inventory);
            }
            catch (DbUpdateException)
            {
                if (InventoryExists(inventory.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }
            return(Ok());
        }
Example #2
0
        public ActionResult CreateProduct(InventoryVM vm)
        {
            var productSKUs = service.GetAllProducts();

            if (productSKUs.Any(a => a.SKU == vm.Product.SKU))
            {
                ModelState.AddModelError("SKU", "A product with this SKU already exists. Please try again.");
                vm.Bins      = service.GetAllBins();
                vm.Products  = service.GetAllProducts();
                vm.Inventory = service.GrabInventory();
                return(View(vm));
            }
            if (ModelState.IsValid)
            {
                service.SaveProduct(vm.Product);
                service.UpdateInventory(vm.Product, vm.SelectBinId);
                return(RedirectToAction("BinHome"));
            }
            else
            {
                vm.Bins      = service.GetAllBins();
                vm.Products  = service.GetAllProducts();
                vm.Inventory = service.GrabInventory();
                return(View(vm));
            }
        }
Example #3
0
        public ActionResult LoginAuthentication(string userName, string password, bool RememberBox)
        {
            Security           active      = new Security();
            var                UController = new UsersController();
            SecurityController SController = new SecurityController(active);
            IVM                model       = new LoginVM(active.IsLoggedIn, active);

            var user = UController.GetU(userName);

            if (user != null)
            {
                var saltHash        = user.PassSalt;
                var encodedPassword = UController.HashPassword(password, saltHash);
                if (user.PassHash.Trim() == encodedPassword.Trim())
                {
                    SController.Login(userName);
                    SController.SetRemember(RememberBox);
                    Login(SController);
                    model = new InventoryVM(userName.Trim(), SController.GetActive());
                    return(View("Inventory", model));
                }
                else
                {
                    ViewBag.ErrorMessage = "Invalid Password";
                }
            }
            else
            {
                ViewBag.ErrorMessage = "Invalid User Name";
            }

            return(View("Index", model));
        }
Example #4
0
        public ActionResult BinHome()
        {
            InventoryVM vm = new InventoryVM();

            vm.Inventory = service.GrabInventory();
            vm.Bins      = service.GetAllBins();
            vm.Products  = service.GetAllProducts();
            foreach (var i in vm.Inventory)
            {
                foreach (var b in vm.Bins)
                {
                    if (b.BinId == i.BinId)
                    {
                        i.BinName = b.BinName;
                    }
                }
                foreach (var p in vm.Products)
                {
                    if (p.ProductId == i.ProductId)
                    {
                        i.ProductDescription = p.ProductDescription;
                        i.SKU = p.SKU;
                    }
                }
            }
            return(View(vm));
        }
Example #5
0
        public ActionResult Index()
        {
            ViewBag.Title = "ACME Vending";


            var inventory = new InventoryVM
            {
                Products = ProdService.LoadMachine()
                           .Select(p => new ProductVM
                {
                    ItemNumber = p.ItemNumber,
                    Name       = p.Name,
                    Price      = p.Price.ToString("c"),
                    Quantity   = p.Quantity
                }).ToList(),
                Cash = new List <CashVM>()
            };

            var till = PayService.LoadMachine();

            //foreach (var billOrCoin in till)
            //{
            //    inventory.Cash.Add(new CashVM { Value = billOrCoin.Value.ToString("c"), Quantity = billOrCoin.Quantity });
            //}

            return(View(inventory));
        }
Example #6
0
        public async Task <IHttpActionResult> PutInventory(InventoryVM inventoryVM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var inventory = new Inventory()
            {
                Id           = inventoryVM.Id,
                Name         = inventoryVM.Name,
                Price        = inventoryVM.Price,
                ModifiedBy   = inventoryVM.ModifiedBy,
                ModifiedDate = DateTime.Now,
            };

            try
            {
                await this._repo.UpdateInventory(inventory);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InventoryExists(inventoryVM.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(Ok(inventoryVM));
        }
Example #7
0
        public ActionResult ChartAnalysis(string actives, string activeLog, string activeRem, string numOfSystems)
        {
            Security           active = session(actives, activeLog, activeRem);
            SecurityController Active = new SecurityController(active);

            if (!(IsLoggedIn(Active).CheckLogin()))
            {
                return(RedirectToAction("Index"));
            }

            // check that numOfSystems is a valid number
            int num;

            if (numOfSystems == null || !int.TryParse(numOfSystems, out num))
            {
                num = 6;
            }

            string uId = Active.GetID();

            Inventory inventory = new Inventory(uId);

            inventory.SortByTotalScore();
            inventory = inventory.GetTop(num);
            InventoryVM model = new InventoryVM(inventory, active);

            return(View(model));
        }
Example #8
0
 public ActionResult UpdateInventory(InventoryVM person)
 {
     humanLg.UpdateInventory(InventoryVM.Map(person));
     ModelState.Clear();
     ViewBag.Message2 = person.inventoryName + " Successfully Updated";
     return(RedirectToAction("DisplayInventory"));
 }
Example #9
0
        public ActionResult Create(InventoryVM inventoryVM)
        {
            if (ModelState.IsValid)
            {
                HttpPostedFileBase[] files = inventoryVM.Files;
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <InventoryVM, Inventory>();
                });

                IMapper mapper = config.CreateMapper();
                inventoryVM.UpdatedAt = DateTime.Now;
                inventoryVM.UpdatedBy = User.Identity.Name;
                Inventory inventory = mapper.Map <InventoryVM, Inventory>(inventoryVM);// Mapper.Map<InventoryVM, Inventory>(inventoryVM);
                db.Inventories.Add(inventory);
                db.SaveChanges();
                int id = db.Inventories.OrderByDescending(m => m.Id).First().Id;

                if (!Directory.Exists(Path.Combine(Server.MapPath("~/Admin/Images/Inventories/Thumb"))))
                {
                    Directory.CreateDirectory(Server.MapPath("~/Admin/Images/Inventories/Thumb"));
                }
                if (inventoryVM.File != null)
                {
                    inventoryVM.File.SaveAs(Server.MapPath("~/Admin/Images/Inventories/Thumb/") + id.ToString() + ".jpg");
                }

                return(RedirectToAction("Index"));
            }

            inventoryVM.Categories = new SelectList(db.Categories, "Id", "Name", inventoryVM.CategoryId);
            inventoryVM.Locations  = new SelectList(db.Locations, "Id", "Name", inventoryVM.LocationId);
            return(View(inventoryVM));
        }
        public IActionResult Inventory()
        {
            ViewBag.Title = "Inventory Overview";

            InventoryVM model = new InventoryVM(_context);

            return(View(model));
        }
Example #11
0
    // all controlers that inherit from this will have
    // the models that are injected into its constructor
    public void Init(GameModel model, PlayerStatusModel psModel, InventoryVM ivm)
    {
        gameModel         = model;
        playerStatusModel = psModel;
        inventoryVM       = ivm;

        OnInitComplete();
    }
Example #12
0
        public IActionResult Index()
        {
            InventoryVM inventoryVM = new InventoryVM()
            {
                Inventories = _inventoryRepository.GetAllInventories(),
                Stores      = _inventoryRepository.GetAllStores()
            };

            return(View(inventoryVM));
        }
Example #13
0
        public ActionResult CreateProduct()
        {
            InventoryVM vm = new InventoryVM();

            vm.Bins      = service.GetAllBins();
            vm.Products  = service.GetAllProducts();
            vm.Inventory = service.GrabInventory();

            return(View(vm));
        }
Example #14
0
        // GET: Inventories/Create
        public ActionResult Create()
        {
            InventoryVM inventoryVM = new InventoryVM();

            inventoryVM.Categories = new SelectList(db.Categories, "Id", "Name");
            inventoryVM.Locations  = new SelectList(db.Locations, "Id", "Name");
            inventoryVM.UpdatedAt  = DateTime.Now;
            inventoryVM.UpdatedBy  = User.Identity.Name;
            return(View(inventoryVM));
        }
        public async Task <ActionResult> Add()
        {
            InventoryVM inventoryVM = new InventoryVM();

            inventoryVM.Categories = new SelectList(await _repo.Categories.GetModel(), "Id", "Name");
            inventoryVM.Locations  = new SelectList(await _repo.Locations.GetModel(), "Id", "Name");
            inventoryVM.UpdatedAt  = DateTime.Now;
            inventoryVM.UpdatedBy  = User.Identity.Name;
            return(View(inventoryVM));
        }
        public async Task <ActionResult> Add(InventoryVM inventoryVM)
        {
            if (ModelState.IsValid)
            {
                IFormFile[] files = inventoryVM.Files;

                inventoryVM.UpdatedAt = DateTime.Now;
                inventoryVM.UpdatedBy = User.Identity.Name;
                Inventory inventory = _mapper.Map <InventoryVM, Inventory>(inventoryVM);
                _repo.Inventories.Insert(inventory);
                _repo.Save();

                IEnumerable <Inventory> inventories = await _repo.Inventories.GetModel();

                int id = inventories.OrderByDescending(m => m.Id).First().Id;


                var folderpath = Path.Combine(_env.ContentRootPath, "wwwroot\\Admin\\images\\Inventories\\Thumb");

                if (!Directory.Exists(folderpath))
                {
                    Directory.CreateDirectory(folderpath);
                }

                string fileName = inventoryVM.File.FileName;
                using (var fileStream = new FileStream(Path.Combine(folderpath, id + ".jpg"), FileMode.Create, FileAccess.Write))
                {
                    inventoryVM.File.CopyTo(fileStream);
                }

                var ImageFolder = Path.Combine(_env.ContentRootPath, "wwwroot\\Admin\\images\\Inventories\\", id.ToString());
                if (inventoryVM.Files != null)
                {
                    if (!Directory.Exists(ImageFolder))
                    {
                        Directory.CreateDirectory(ImageFolder);
                    }
                }


                foreach (var file in inventoryVM.Files)
                {
                    using (var fileStream = new FileStream(Path.Combine(ImageFolder, file.FileName), FileMode.Create, FileAccess.Write))
                    {
                        file.CopyTo(fileStream);
                    }
                }

                return(RedirectToAction("Index"));
            }

            inventoryVM.Categories = new SelectList(await _repo.Categories.GetModel(), "Id", "Name", inventoryVM.CategoryId);
            inventoryVM.Locations  = new SelectList(await _repo.Locations.GetModel(), "Id", "Name", inventoryVM.LocationId);
            return(View(inventoryVM));
        }
    public void Init(InventoryVM ivm)
    {
        // register th inventory view model events
        // in order to update the displays of the items
        // everytime there is a change inside the
        // inventory view model

        inventoryVM = ivm;
        inventoryVM.OnItemsChanged -= OnItemChanged;
        inventoryVM.OnItemsChanged += OnItemChanged;
    }
Example #18
0
        public ActionResult Registration(string actives, string activeLog, string activeRem)
        {
            Security           active = session(actives, activeLog, activeRem);
            SecurityController Active = new SecurityController(active);
            IVM model = new SecurityVM(active);

            if (IsLoggedIn(Active).CheckLogin())
            {
                model = new InventoryVM(Active.GetID(), Active.GetActive());
                return(View("Inventory", model));
            }

            return(View(model));
        }
Example #19
0
        public async Task <IHttpActionResult> GetInventory(Guid id)
        {
            var inventory = await this._repo.GetInventory(id);

            if (inventory == null)
            {
                return(NotFound());
            }
            var inventoryVM = new InventoryVM()
            {
                Id    = inventory.Id,
                Name  = inventory.Name,
                Price = inventory.Price,
            };

            return(Ok(inventoryVM));
        }
Example #20
0
        public ActionResult TextAnalysis(string actives, string activeLog, string activeRem)
        {
            Security           active = session(actives, activeLog, activeRem);
            SecurityController Active = new SecurityController(active);

            if (!(IsLoggedIn(Active).CheckLogin()))
            {
                return(RedirectToAction("Index"));
            }

            string    uId       = Active.GetID();
            Inventory inventory = new Inventory(uId);

            inventory.SortByTotalScore();
            inventory = inventory.GetTop(6);
            InventoryVM model = new InventoryVM(inventory, active);

            return(View(model));
        }
Example #21
0
        public ActionResult DeleteSurvey(string actives, string activeLog, string activeRem, int aId)
        {
            Security           active = session(actives, activeLog, activeRem);
            SecurityController Active = new SecurityController(active);
            AnswersController  a      = new AnswersController();

            if (!(IsLoggedIn(Active).CheckLogin()))
            {
                return(RedirectToAction("Index"));
            }

            string uId = Active.GetID();

            a.DeleteWholeAnswer(uId, aId);

            InventoryVM model = new InventoryVM(uId, active);

            return(RedirectToAction("Inventory", model));
        }
        public async Task <ActionResult> Edit(int?id)
        {
            if (id.HasValue)
            {
                InventoryVM inventoryVM = new InventoryVM();
                Inventory   inventory   = await _repo.Inventories.GetById(id.Value);

                inventoryVM            = _mapper.Map <Inventory, InventoryVM>(inventory);
                inventoryVM.Categories = new SelectList(await _repo.Categories.GetModel(), "Id", "Name", inventory.CategoryId);
                inventoryVM.Locations  = new SelectList(await _repo.Locations.GetModel(), "Id", "Name", inventory.LocationId);
                inventoryVM.UpdatedAt  = DateTime.Now;
                inventoryVM.UpdatedBy  = User.Identity.Name;
                return(View(inventoryVM));
            }
            else
            {
                return(BadRequest());
            }
        }
Example #23
0
        public IActionResult OnGet(int?id)
        {
            InventoryVM = new InventoryVM()
            {
                Inventory    = new Models.Inventory(),
                UnitTypeList = _unitOfWork.UnitType.GetUnitTypeListForDropdown()
            };

            if (id != null)
            {
                InventoryVM.Inventory = _unitOfWork.Inventory.GetFirstOrDefault(x => x.Id == id);

                if (InventoryVM.Inventory == null)
                {
                    return(NotFound());
                }
            }

            return(Page());
        }
Example #24
0
        public ActionResult Edit(int?id, InventoryVM inventoryVM)
        {
            if (ModelState.IsValid)
            {
                Inventory inventory = db.Inventories.Find(id);
                var       config    = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <InventoryVM, Inventory>();
                });
                HttpPostedFileBase[] files = inventoryVM.Files;

                IMapper mapper = config.CreateMapper();

                inventoryVM.UpdatedAt = DateTime.Now;

                inventoryVM.UpdatedBy = User.Identity.Name;
                inventory             = mapper.Map <InventoryVM, Inventory>(inventoryVM);
                if (TryUpdateModel(inventory))
                {
                    db.SaveChanges();
                }
                //db.Entry(inventory).State = EntityState.Modified;
                if (!Directory.Exists(Path.Combine(Server.MapPath("~/Admin/Images/Inventories/Thumb"))))
                {
                    Directory.CreateDirectory(Server.MapPath("~/Admin/Images/Inventories/Thumb"));
                }


                if (inventoryVM.File != null)
                {
                    inventoryVM.File.SaveAs(Server.MapPath("~/Admin/Images/Inventories/Thumb/") + id.ToString() + ".jpg");
                }


                return(RedirectToAction("Index"));
            }
            inventoryVM.Categories = new SelectList(db.Categories, "Id", "Name", inventoryVM.CategoryId);
            inventoryVM.Locations  = new SelectList(db.Locations, "Id", "Name", inventoryVM.LocationId);
            return(View(inventoryVM));
        }
Example #25
0
        // GET: Inventories/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Inventory inventory = db.Inventories.Find(id);
            var       config    = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Inventory, InventoryVM>();
            });

            IMapper mapper = config.CreateMapper();

            inventory.Date = DateTime.Now;
            InventoryVM inventoryVM = mapper.Map <Inventory, InventoryVM>(inventory);

            if (Directory.Exists(Server.MapPath("~/Admin/Images/Inventories/" + id.ToString())))
            {
                string[] files = Directory.GetFiles(Server.MapPath("~/Admin/Images/Inventories/" + id.ToString()));

                if (files != null)
                {
                    if (files.Length > 0)
                    {
                        inventoryVM.Images = files;
                    }
                }
            }
            if (inventory == null)
            {
                return(HttpNotFound());
            }
            inventoryVM.Categories = new SelectList(db.Categories, "Id", "Name", inventory.CategoryId);
            inventoryVM.Locations  = new SelectList(db.Locations, "Id", "Name", inventory.LocationId);
            return(View(inventoryVM));
        }
Example #26
0
    IEnumerator LoadGameData()
    {
        // get the game model
        gameModel = new GameModel();

        // set the gamedata.xml file path
        gameModel.DataPath = Application.streamingAssetsPath + "/Data/gamedata.xml";
        // load the game data into the model
        gameModel.Load();

        // get the player status model
        playerStatusModel          = new PlayerStatusModel();
        playerStatusModel.DataPath = Application.streamingAssetsPath + "/Data/player_status.xml";
        playerStatusModel.Clear();

        // init the inventory VM
        inventoryVM = new InventoryVM();
        inventoryVM.AvailableItems = gameModel.AvailableItems;

        yield return(null);

        // the game data should be ready at this point.
        OnGameDataReady();
    }
Example #27
0
        public ActionResult PostUser(User user)
        {
            Security           active = session(user.ID, "False", "False");
            UsersController    u      = new UsersController();
            SecurityController SC     = new SecurityController(active);
            IVM model = new LoginVM(active.IsLoggedIn, active);

            var getUser = u.GetU(user.ID);

            if (getUser == null)
            {
                if (user.FName == null)
                {
                    user.FName = "";
                }
                if (user.LName == null)
                {
                    user.LName = "";
                }
                if (user.Organization == null)
                {
                    user.Organization = "";
                }
                SC.Login(user.ID);
                Login(SC);
                UController.PostUser(user);
                model = new InventoryVM(SC.GetID(), active);
                return(View("Inventory", model));
            }
            else
            {
                ViewBag.ErrorMessage = "Email already registered";
            }
            model = new SecurityVM(active);
            return(View("Registration", model));
        }
Example #28
0
        public ActionResult Inventory(string sort, string actives, string activeLog, string activeRem)
        {
            Security           active = session(actives, activeLog, activeRem);
            SecurityController Active = new SecurityController(active);

            if (!(IsLoggedIn(Active).CheckLogin()))
            {
                return(RedirectToAction("Index"));
            }

            Inventory inventory = new Inventory(Active.GetID());

            inventory.SortByLastUsed();
            int section;

            if (sort == "name")
            {
                inventory.SortByName();
            }
            else if (sort == "lastUsed")
            {
                inventory.SortByLastUsed();
            }
            else if (sort == "totalScore")
            {
                inventory.SortByTotalScore();
            }
            else if (int.TryParse(sort, out section))
            {
                inventory.SortBySectionScore(section);
            }

            InventoryVM model = new InventoryVM(inventory, active);

            return(View(model));
        }
Example #29
0
        public ActionResult UpdateInventory(int id)
        {
            InventoryVM human = InventoryVM.Map(humanLg.GetInventoryInfoByInventoryID(id));

            return(View(human));
        }
Example #30
0
 public ActionResult DisplayInventoryCustomer()
 {
     return(View(InventoryVM.Map(humanLg.DisplayInventory())));
 }