Esempio n. 1
0
        public ActionResult AddMaterial(int?id)
        {
            AddMaterialModel model = new AddMaterialModel();

            model.MeasureId        = id.Value;
            model.MaterialTypeList = db.MaterialTypes.ToList().Select(i => new Lookup(i.Id, i.Description)).ToList();
            model.WidthList        = db.Widths.ToList();
            return(View(model));
        }
Esempio n. 2
0
 public IActionResult AddMaterial(AddMaterialModel model)
 {
     if (!ModelState.IsValid)
     {
         return(RedirectToAction("Error", "Home", new { errorType = 2 }));
     }
     if (model.Name == null)
     {
         return(RedirectToAction("Error", "Home", new { errorType = 3 }));
     }
     _materials.AddMaterial(new Material {
         Name = model.Name
     });
     return(RedirectToAction("AdminProducts", "Admin"));
 }
Esempio n. 3
0
 public ActionResult AddMaterial(AddMaterialModel model)
 {
     if (ModelState.IsValid)
     {
         Measure m = db.Measures.Find(model.MeasureId);
         if (m != null)
         {
             MeasureMaterial mm = new MeasureMaterial()
             {
                 MaterialTypeId     = model.MaterialTypeId.Value,
                 AltWidthId         = model.AltWidthId,
                 WidthId            = model.WidthId,
                 Description        = model.Description,
                 PatternMatchWidth  = model.PatternWidth,
                 PatternMatchLength = model.PatternLength
             };
             m.Materials.Add(mm);
             int c = db.SaveChanges();
             return(RedirectToAction("Details/" + model.MeasureId.ToString()));
         }
     }
     return(View(model));
 }