예제 #1
0
        public bool addWorker(Person p)
        {
            Person tmp = vse.Person.Find(p.PersonID);

            if (tmp == null)
            {
                vse.Person.Add(p);
                vse.SaveChanges();

                return true;
            }
            else 
            {
                return false;
            }
        }
예제 #2
0
        public ActionResult EditPerson(Person p)
        {
            if (ModelState.IsValid)
            {
                if (dbm.updatePerson(p))
                {
                    string output = p.fullName() + " has been updated";
                    TempData["Success"] = output;
                }
                else 
                {
                    string output = p.fullName() + " could not be updated";
                    TempData["Failure"] = output;  
                }

                return RedirectToAction("People");
            }

            return View(p);
        }
예제 #3
0
        public ActionResult CreateJob(PeopleJobvm pjvm)
        {

            if (ModelState.IsValid)
            {
            Vaktir vakt = new Vaktir();
            vakt.Date = pjvm.job.Date;
            vakt.End = pjvm.job.End;
            vakt.Start = pjvm.job.Start;
            vakt.Type = pjvm.job.Type;
            vakt.PersonID = pjvm.job.PersonID;

            string id = pjvm.job.PersonID;
            vakt.Type = pjvm.job.Type;
            Person vaktPerson = new Person();

            vaktPerson = dbm.allPeoples.Find(x => x.PersonID.Equals(id));
            vakt.Person = vaktPerson;
            dbm.addJob(vakt);

                String output = "Vakt no: " + vakt.VaktID + " has been added to database";
                TempData["Success"] = output;

            return RedirectToAction("Jobs");
        }

            pjvm.ListOfPersons = dbm.allPeoples;
            return View(pjvm);
        }
예제 #4
0
        public ActionResult CreatePerson(Person p)
        {

            if (ModelState.IsValid)
            {
               if(dbm.addWorker(p))
               {
                   String output = p.fullName() + " has been added to database";
                   TempData["Success"] = output;
               }
               else 
               {
                   String output = "person id has to be unique";
                   TempData["Failure"] = output;
               }

                return RedirectToAction("People");
            }
            return View();
        }
예제 #5
0
 public void deletePerson(Person p)
 {
     if(p != null)
     {
         vse.Person.Remove(p);
         vse.SaveChanges();
     }
 }
예제 #6
0
        public bool updatePerson(Person p)
        {
            Person tmp = vse.Person.Find(p.PersonID);

            if(tmp != null)
            {

                vse.Person.Find(p.PersonID).FirstName = p.FirstName;
                vse.Person.Find(p.PersonID).LastName = p.LastName;
                vse.Person.Find(p.PersonID).Telephone = p.Telephone;
                vse.Person.Find(p.PersonID).PersonID = p.PersonID;
                vse.Person.Find(p.PersonID).Password = p.Password;
                vse.SaveChanges();
                return true;
            }
            else 
            {
                return false;
            }
        }