public ActionResult Index()
        {
            var repo  = new MobileSuitRepositoryADO();
            var model = repo.GetRecent();

            return(View(model));
        }
        public ActionResult MassProducedInventory()
        {
            var repo  = new MobileSuitRepositoryADO();
            var model = repo.GetMassProduced();

            return(View(model));
        }
        public void CanLoadBroken()
        {
            var repo = new MobileSuitRepositoryADO();
            List <Mobile_Suit_Search_Result> gundams = repo.GetBroken().ToList();

            Assert.AreEqual(0, gundams.Count());
        }
        public void CanInsertMobileSuit()
        {
            Mobile_Suit MobileSuit = new Mobile_Suit();
            var         repo       = new MobileSuitRepositoryADO();

            MobileSuit.UserID       = "11111111-1111-1111-1111-111111111111";
            MobileSuit.BodyStyleID  = 1;
            MobileSuit.ColorID      = 2;
            MobileSuit.Interior     = 2;
            MobileSuit.Description  = "Custom Red Zaku II, Customized for peak performance for commanders of the Zeon army. 3x Faster than the base model with an added shield attatchment. ";
            MobileSuit.MakeModelID  = 2;
            MobileSuit.MSRP         = 120000;
            MobileSuit.SalePrice    = 100000;
            MobileSuit.SerialNumber = "0123456789";
            MobileSuit.TypeID       = 2;
            MobileSuit.WeaponID     = 1;
            MobileSuit.Year         = 0079;
            MobileSuit.Name         = "Zaku II Commander Type";
            MobileSuit.Image        = "Placeholder.Jpeg";
            MobileSuit.CenturyID    = 1;
            MobileSuit.Featured     = true;


            repo.Insert(MobileSuit);

            Assert.AreEqual(7, MobileSuit.InventoryNumber);
        }
Пример #5
0
        public ActionResult MobileSuits()
        {
            var repo  = new MobileSuitRepositoryADO();
            var model = repo.GetAll();

            if (User.Identity.IsAuthenticated)
            {
                var user = User.Identity;
                ViewBag.Name = user.Name;

                ViewBag.displayMenu = "No";

                if (IsAdminUser())
                {
                    ViewBag.displayMenu = "Yes";
                }

                return(View(model));
            }
            else
            {
                ViewBag.Name = "Not Logged IN";
                return(View(model));
            }
        }
        public ActionResult BrokenInventory()
        {
            var repo  = new MobileSuitRepositoryADO();
            var model = repo.GetBroken();

            return(View(model));
        }
        public void CanLoadMobileSuit()
        {
            var repo = new MobileSuitRepositoryADO();

            var MobileSuit = repo.GetById(1);

            Assert.AreEqual("Zaku II", MobileSuit.Name.ToString());
        }
        public void CanSelectByModel()
        {
            var    repo  = new MobileSuitRepositoryADO();
            string Model = "06";
            var    list  = repo.GetByModel(Model);

            Assert.AreEqual(2, list.Count());
        }
        public void CanSelectByMake()
        {
            var    repo = new MobileSuitRepositoryADO();
            string Make = "MS";
            var    list = repo.GetByMake(Make);

            Assert.AreEqual(3, list.Count());
        }
        public void CanSelectByPrice()
        {
            var repo  = new MobileSuitRepositoryADO();
            int price = 1000000;
            var list  = repo.GetByPrice(price);

            Assert.AreEqual(3, list.Count());
        }
        public void CanSelectByYear()
        {
            var repo = new MobileSuitRepositoryADO();
            int year = 79;
            var list = repo.GetByYear(year);

            Assert.AreEqual(6, list.Count());
        }
        public void CanLoadMassProduced()
        {
            var repo = new MobileSuitRepositoryADO();
            List <Mobile_Suit_Search_Result> gundams = repo.GetMassProduced().ToList();

            Assert.AreEqual(4, gundams.Count());
            Assert.AreEqual(1, gundams[0].InventoryNumber);
        }
        public void FailLoadMobileSuit()
        {
            var repo = new MobileSuitRepositoryADO();

            var MobileSuit = repo.GetById(1);

            Assert.IsNull(MobileSuit);
        }
        public void CanLoadRecentGundam()
        {
            var repo = new MobileSuitRepositoryADO();
            List <Featured_Item> gundams = repo.GetRecent().ToList();

            Assert.AreEqual(6, gundams.Count());
            Assert.AreEqual(1, gundams[0].InventoryNumber);
        }
        public void CanLoadGundamDetails()
        {
            var           repo    = new MobileSuitRepositoryADO();
            Detail_Result gundams = repo.GetDetails(2);

            Assert.AreEqual("UC", gundams.Century);
            Assert.AreEqual(79, gundams.Year);
            Assert.AreEqual("Custom", gundams.Type);
            Assert.AreEqual("Red", gundams.Interior);
            Assert.AreEqual("Red", gundams.Color);
            Assert.AreEqual("Zaku II Char Custom", gundams.Name);
        }
        public ActionResult Details(int id)
        {
            if (Request.IsAuthenticated)
            {
                ViewBag.UserId = AuthorizeUtilities.GetUserId(this);
            }
            var repo  = new MobileSuitRepositoryADO();
            var model = repo.GetDetails(id);


            return(View(model));
        }
Пример #17
0
        public IHttpActionResult Search(decimal?minRate, decimal?maxRate, string make, string model)
        {
            var repo = new MobileSuitRepositoryADO();

            try
            {
                var parameters = new MobileSuitSearchParametersSales()
                {
                    MinRate = minRate,
                    MaxRate = maxRate,
                    Make    = make,
                    Model   = model,
                };

                var result = repo.SaleSearch(parameters);
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #18
0
        public ActionResult Details(int id)
        {
            var repo       = new MobileSuitRepositoryADO();
            var modelfirst = repo.GetDetails(id);
            var model      = new SalesViewModel();
            var statesrepo = new StateRepositoryADO();

            model.States = new SelectList(statesrepo.GetAll(), "StateId", "Name");
            var purchaseRepo = new PurchaseRepoADO();

            model.Purchase = new SelectList(purchaseRepo.GetAll(), "TypeId", "Type");


            model.MobileSuit = modelfirst;
            if (User.Identity.IsAuthenticated)
            {
                var user = User.Identity;
                ViewBag.Name = user.Name;

                ViewBag.displayMenu = "No";

                if (IsAdminUser())
                {
                    ViewBag.displayMenu = "Yes";
                }
                if (Request.IsAuthenticated)
                {
                    ViewBag.UserId = AuthorizeUtilities.GetUserId(this);
                }
                return(View(model));
            }
            else
            {
                ViewBag.Name = "Not Logged IN";
                return(View(model));
            }
        }
Пример #19
0
        public ActionResult Add(AddMobileSuitViewModel model)
        {
            var user = User.Identity;

            model.MobileSuit.UserID = user.GetUserId();

            var MakeModelCheck = new MakeModelrepo();
            var test           = MakeModelCheck.GetByBoth(model.MobileSuit.MakeID, model.MobileSuit.ModelID);

            if (test.MakeModelID == 0)
            {
                var temp = MakeModelCheck.Insert(model.MobileSuit.MakeID, model.MobileSuit.ModelID);
                model.MobileSuit.MakeModelID = temp;
            }
            else
            {
                model.MobileSuit.MakeModelID = test.MakeModelID;
            }



            if (ModelState.IsValid)
            {
                var repo = new MobileSuitRepositoryADO();

                try
                {
                    var savepath = Server.MapPath("~/Images");

                    string fileName  = Path.GetFileNameWithoutExtension(model.ImageUpload.FileName);
                    string extension = Path.GetExtension(model.ImageUpload.FileName);

                    var filePath = Path.Combine(savepath, fileName + extension);

                    int counter = 1;
                    while (System.IO.File.Exists(filePath))
                    {
                        filePath = Path.Combine(savepath, fileName + counter.ToString() + extension);
                        counter++;
                    }

                    model.ImageUpload.SaveAs(filePath);

                    model.MobileSuit.Image = Path.GetFileName(filePath);

                    repo.Insert(model.MobileSuit);

                    return(RedirectToAction("MobileSuits", "Admin"));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                var model2      = new AddMobileSuitViewModel();
                var TypeRepo    = new TypeRepositoryADO();
                var BodyRepo    = new BodyStylesRepoADO();
                var CenturyRepo = new CenturyRepoADO();
                var ColorRepo   = new ColorRepoADO();
                var ModelRepo   = new ModelRepoADO();
                var MakeRepo    = new MakeRepoADO();
                var WeaponRepo  = new WeaponRepoADO();

                model2.Types = new SelectList(TypeRepo.GetAll(), "TypeId", "Name");

                model2.BodyStyles = new SelectList(BodyRepo.GetAll(), "BodyStyleId", "Name");

                model2.Centuries = new SelectList(CenturyRepo.GetAll(), "CenturyId", "CenturyName");

                model2.Colors  = new SelectList(ColorRepo.GetAll(), "ColorId", "Name");
                model2.Models  = new SelectList(ModelRepo.GetAll(), "ModelId", "Name");
                model2.Makes   = new SelectList(MakeRepo.GetAll(), "MakeId", "Name");
                model2.Weapons = new SelectList(WeaponRepo.GetAll(), "WeaponId", "WeaponName");


                return(View(model2));
            }
        }