Ejemplo n.º 1
0
        public ActionResult CreatePeople(int companyid = 0)
        {
            Company company = db.Companies.Find(companyid);
            if (company == null)
                HttpNotFound();
            People ppl = new People();
            ppl.CompanyId = companyid;
            List<int> types = new List<int>();

            ViewBag.PeopleTypeList = new MultiSelectList(db.PeopleTypes.ToList(), "PeopleTypeId", "Title", types);
            //ViewBag.PeopleTypeList = new SelectList(db.PeopleTypes.ToList(), "PeopleTypeId", "Title");
            //ViewBag.LanguageList = new SelectList(db.Language.ToList(), "LanguageId", "Title");
            return View(ppl);
        }
Ejemplo n.º 2
0
 public ActionResult CreatePeople(People type)
 {
     if (type.PeopleTypes == null)
         type.PeopleTypes = new List<PeopleType>();
     foreach (string ptype in Request.Form["SelectPeopleType"].Split(','))
     {
         PeopleType peopleType = db.PeopleTypes.Find(Int16.Parse(ptype));
         type.PeopleTypes.Add(peopleType);
     }
      /*   if (type.PeopleTypeId == 0)
     {
         type.PeopleTypeId = Int16.Parse(this.Request.Form.Get("PeopleTypeList"));
     }
     */
     if (ModelState.IsValid)
     {
         Company company = db.Companies.Find(type.CompanyId);
         company.Revision++;
         db.Entry(company).State = EntityState.Modified;
         db.Peoples.Add(type);
         db.SaveChanges();
         return RedirectToAction("Details", new { id = type.CompanyId });
     }
     List<int> types = new List<int>();
     foreach (var peopleType in type.PeopleTypes)
         types.Add(peopleType.PeopleTypeId);
     ViewBag.PeopleTypeList = new MultiSelectList(db.PeopleTypes.ToList(), "PeopleTypeId", "Title", types);
        // ViewBag.PeopleTypeList = new SelectList(db.PeopleTypes.ToList(), "PeopleTypeId", "Title", type.PeopleType.PeopleTypeId);
     return View(type);
 }
Ejemplo n.º 3
0
 public ActionResult EditPeople(People type)
 {
     if (ModelState.IsValid)
     {
         db.Database.ExecuteSqlCommand("DELETE FROM PeopleJoinPeopleType WHERE PeopleId=" + type.PeopleId.ToString());
         db.Entry(type).State = EntityState.Modified;
         var ptypes = Request.Form["SelectPeopleType"].Split(',').ToList();
         type.PeopleTypes = new List<PeopleType>();
         foreach (string ptype in ptypes)
         {
             PeopleType peopleType = db.PeopleTypes.Find(Int16.Parse(ptype));
             type.PeopleTypes.Add(peopleType);
         }
         Company company = db.Companies.Find(type.CompanyId);
         company.Revision++;
         db.Entry(company).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Details", new { id = type.CompanyId });
     }
     List<int> types = new List<int>();
     foreach (var peopleType in type.PeopleTypes)
         types.Add(peopleType.PeopleTypeId);
     ViewBag.PeopleTypeList = new MultiSelectList(db.PeopleTypes.ToList(), "PeopleTypeId", "Title", types);
     return View("CreateCompanyLink", type);
 }