Ejemplo n.º 1
0
 public TypeToType ToTypeToType(ViewTypeToType typetotypeV)
 {
     return new TypeToType()
     {
         Id = typetotypeV.IdV,
         IdParent = typetotypeV.IdParentV,
         IdSub = typetotypeV.IdSubV,
         Type = typetotypeV.ParentTypeV,
         Type1 = typetotypeV.SubTypeV
     };
 }
Ejemplo n.º 2
0
        public bool ValTypeToType(ViewTypeToType typetotypeV)
        {
            bool exist = false;

            foreach (var item in db.TypeToTypes)
            {
                if (typetotypeV.IdParentV == item.IdParent && typetotypeV.IdSubV == item.IdSub)
                {
                    exist = true;
                }
            }
            return exist;
        }
Ejemplo n.º 3
0
        public ActionResult Create(ViewTypeToType typetotypeV)
        {
            if (ModelState.IsValid)
            {
                if (val.ValTypeToType(typetotypeV))
                {
                    TempData["validation"] = "istnieje";

                    return RedirectToAction("Create");
                }
                else
                {
                    db.TypeToTypes.Add(swap.ToTypeToType(typetotypeV));
                    db.SaveChanges();
                }
                return RedirectToAction("Index");
            }

            ViewBag.IdParentV = new SelectList(db.Types, "Id", "Name", typetotypeV.IdParentV);
            ViewBag.IdSubV = new SelectList(db.Types, "Id", "Name", typetotypeV.IdSubV);
            return View(typetotypeV);
        }
Ejemplo n.º 4
0
        // GET: /TypeToType/
        public ViewResult Index()
        {
            ViewTypeToType model = new ViewTypeToType();
            model.ListTypeToType = db.TypeToTypes.ToList();

            #region DeleteRepead

            List<int> NoR = new List<int>();
            foreach (var item in model.ListTypeToType)
            {
                NoR.Add(item.IdParent);
            }
            model.NoRepeadParent = NoR.Distinct();

            #endregion

            return View(model);
        }
Ejemplo n.º 5
0
        public ActionResult Edit(ViewTypeToType typetotypeV)
        {
            if (ModelState.IsValid)
            {
                if (val.ValTypeToType(typetotypeV))
                {
                    TempData["validation"] = "istnieje";

                    return RedirectToAction("Edit");
                }
                else
                {
                    TypeToType typetotypeOrg = db.TypeToTypes.First(p => p.Id == typetotypeV.IdV);
                    typetotypeOrg.IdParent = typetotypeV.IdParentV;
                    typetotypeOrg.IdSub = typetotypeV.IdSubV;
                    typetotypeOrg.Type = typetotypeV.ParentTypeV;
                    typetotypeOrg.Type1 = typetotypeV.SubTypeV;

                    db.SaveChanges();

                    return RedirectToAction("Index");
                }
            }
            ViewBag.IdParentV = new SelectList(db.Types, "Id", "Name", typetotypeV.IdParentV);
            ViewBag.IdSubV = new SelectList(db.Types, "Id", "Name", typetotypeV.IdSubV);
            return View(typetotypeV);
        }