示例#1
0
        public ActionResult Add()
        {
            VMModelAdd vmModel = new VMModelAdd();

            vmModel.Makes = MakeDAL.GetList(x => x.IsActive == true);
            return(View(vmModel));
        }
示例#2
0
        public ActionResult Add(ProductModel model)
        {
            ProductModel pm = new ProductModel();

            pm.ModelID    = Guid.NewGuid();
            pm.ModelName  = model.ModelName;
            pm.MakeID     = model.MakeID;
            pm.CategoryID = model.CategoryID;
            pm.IsActive   = true;

            Make m = MakeDAL.Get(x => x.MakeID == model.MakeID);

            if (m.Categories.Where(x => x.CategoryID == model.CategoryID && x.IsActive == true) != null && ModelState.IsValid && ProductModelDAL.Get(x => x.ModelName == model.ModelName) == null)
            {
                ProductModelDAL.Add(pm);
                return(RedirectToAction("Index", "ProductModel"));
            }
            else
            {
                VMModelAdd vmModel = new VMModelAdd();
                vmModel.Makes = MakeDAL.GetList(x => x.IsActive == true);
                return(View(vmModel));
            }
        }