protected Model GetFirstModel()
        {
            IList <Model> entityList = manager.GetAll(1);

            if (entityList.Count == 0)
            {
                Assert.Fail("All tables must have at least one row for unit tests to succeed.");
            }
            return(entityList[0]);
        }
Пример #2
0
        public ActionResult Create(Model model)
        {
            ViewBag.ManufacturerList = GetManufacturers();
            ViewBag.CategoryList     = GetCategories();

            if (ModelState.IsValid && model != null)
            {
                ModelState.Clear();
                try
                {
                    var modelList = _modelManager.GetAll(c => true);

                    int modelExist = modelList
                                     .Where(c => c.ManufacuturerId == model.ManufacuturerId)
                                     .Where(c => c.CategoryId == model.CategoryId)
                                     .Where(c => c.Name == model.Name)
                                     .Count();

                    if (modelExist > 0)
                    {
                        model.Name = null;
                        ModelState.AddModelError("Name",
                                                 "Model already exists.");
                    }
                    else
                    {
                        if (_modelManager.Add(model))
                        {
                            ViewBag.Msg = "model added successfully!";
                            return(View());
                        }
                    }
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.Message);
                }
            }

            return(View(model));
        }
        protected PhuTung CreateNewPhuTung()
        {
            PhuTung entity = new PhuTung();


            entity.MaSoPhuTung   = "Test Te";
            entity.TenPhuTung    = "Test Test Test Test Test Test T";
            entity.SoLuong       = 82;
            entity.DonVi         = "Te";
            entity.TongTienVon   = 99;
            entity.GiaVonTren1DV = 6;
            entity.GiaBanTren1DV = 60;
            entity.GhiChu        = "Test Test ";

            IModelManager modelManager = managerFactory.GetModelManager();

            entity.ModelMember = modelManager.GetAll(1)[0];

            return(entity);
        }
 // GET: Assets/Create
 public ActionResult Create()
 {
     ViewBag.ModelId = new SelectList(_modelManager.GetAll(), "Id", "Name");
     return(View());
 }
Пример #5
0
        // GET: Model
        public ActionResult Index()
        {
            var models = _modelManager.GetAll();

            return(View(models.ToList()));
        }