Exemplo n.º 1
0
 public assembly(assembly copy){
     id = copy.id;
     name = copy.name;
     comment = copy.comment;
     locked = copy.locked;
     tags = copy.tags;
     parent = copy.parent;
     weight = copy.weight;
     volume = copy.volume;
     retail = copy.retail;
     wholesale = copy.wholesale;
 }
Exemplo n.º 2
0
 public assembly(assembly copy)
 {
     id        = copy.id;
     name      = copy.name;
     comment   = copy.comment;
     locked    = copy.locked;
     tags      = copy.tags;
     parent    = copy.parent;
     weight    = copy.weight;
     volume    = copy.volume;
     retail    = copy.retail;
     wholesale = copy.wholesale;
 }
    public ActionResult Create(AssembleRegisterModel assembly)
    {
      if (ModelState.IsValid)
      {

        Models.assembly new_assembly = new Models.assembly(assembly);
        db.assemblies.Add(new_assembly);
        db.SaveChanges();

        JObject assets = JObject.Parse(assembly.assets);
        foreach (var asset in assets)
        {
          db.assembly_assets.Add(new Models.assembly_assets(new_assembly.id, int.Parse(asset.Key), (int) asset.Value, ""));
        }
        db.SaveChanges();

        return RedirectToAction("Index");
      }

      ViewBag.assetinfo = assembly.assets;
      ViewBag.assets = db.assets.ToList();

      return View(assembly);
    }
    public ActionResult Edit(AssembleRegisterModel assembly)
    {
      if (ModelState.IsValid)
      {

        Models.assembly new_assembly = new Models.assembly(assembly);
        db.Entry(new_assembly).State = EntityState.Modified;

        foreach (var row in db.assembly_assets.Where(aa => aa.assembly_id == assembly.id))
        {
          db.assembly_assets.Remove(row);
        }

        JObject components = JObject.Parse(assembly.assets);

        foreach (var prop in components)
        {
          db.assembly_assets.Add(new Models.assembly_assets ( assembly.id, int.Parse(prop.Key), (int)prop.Value,  "" ));

        }
        db.SaveChanges();

        return RedirectToAction("Index");
      }

      ViewBag.assetinfo = assembly.assets;
      ViewBag.assets = db.assets.ToList();

      return View(assembly);
    }