Exemplo n.º 1
0
        public string GetData(int id, bool mod)
        {
            //return string.Format("You entered: {0}", id);
            //TODO zwracanie obiektu zawierajacego dane

            SDOModelMethods sdomm = new SDOModelMethods();
            Person p = new Person();
            if (mod == false)
            {
            try
            {
                p = sdomm.getPerson(id);
            }
            catch (Exception e)
            {
                return e.Message;
            }
            //return string.Format("{0} {1}, {2}, student: {3}", p.Name, p.Surname, p.Email, p.Student);
            }
            else
            {
                try
                {
                    p = sdomm.getPersonByGLID(id);
                }
                catch (Exception e)
                {
                    return e.Message;
                }
                //return p.pssl.ToString();
            }
            return string.Format("{0}%%%{1}%%%{2}%%%{3}%%%{4}%%%{5}", p.Name, p.Surname, p.Email, p.pssl, p.Student, p.Id);
        }
Exemplo n.º 2
0
        public string AddNewStudentLame(string _name, string _surn, bool batman, string plid, string _mail)
        {
            //InteractionModels.SDOLocalMethods1 sdolm = new InteractionModels.SDOLocalMethods1();
            //sdolm.addPerson(_name, _surn, batman, _mail);

            service1VC.incrementVersion("Adding new Student...");
            SDOModelMethods sdomm = new SDOModelMethods();
            Person O = new Person();
            O = sdomm.getPersonByGLID(Convert.ToInt32(plid));
            if (O != null)
            {
                service1VC.incrementVersion("ERR: Student already exists!");
                return "Już jest ktoś taki. Aborting.";
            }
            else
            {
                try
                {
                    sdomm.addPerson(_name, _surn, batman, plid, _mail);
                }
                catch (Exception e)
                {
                    service1VC.incrementVersion("ERR: Unknown error while saving new Student data!");
                    return e.Message;
                }

                service1VC.incrementVersion("Student successfully added.");
                return "Done";
            }
        }
Exemplo n.º 3
0
        public Person getPerson(int id)
        {
            DBEntities db = new DBEntities();
            Person r = new Person();

            r = (from rr in db.People
                 where rr.Id == id
                 select rr).First();

            return r;
        }
Exemplo n.º 4
0
        public void deletePerson(int id)
        {
            DBEntities db = new DBEntities();
            Person r = new Person();

            r = (from rr in db.People
                 where rr.Id == id
                 select rr).First();

            db.People.Remove(r);
            db.SaveChanges();
        }
Exemplo n.º 5
0
        public void addPerson(string name, string surname, bool student, string pld, string email)
        {
            DBEntities db = new DBEntities();

            Person p = new Person();

            p.Name = name;
            p.Surname = surname;
            p.Student = student;
            p.pssl = Convert.ToInt32(pld);
            p.Email = email;

            db.People.Add(p);
            db.SaveChanges();
        }
Exemplo n.º 6
0
 public List<String> GetMatchingSurnames(string __surname)
 {
     DBEntities db = new DBEntities();
     Person p = new Person();
     var query = from r in db.People
                 where r.Surname == __surname
                 select r;
     var qry = query.ToList();
     var qrarr = new List<String>();
     foreach (Person pp in qry)
     {
         // Don't make me ever do this again.
         qrarr.Add(string.Format("{0}%%%{1}%%%{2}%%%{3}%%%{4}", pp.Name, pp.Surname, pp.Email, pp.pssl, pp.Student));
     }
     return qrarr;
 }
Exemplo n.º 7
0
        public Person getPersonByGLID(int pss)
        {
            DBEntities db = new DBEntities();
            Person r = new Person();

            r = (from rr in db.People
                        where rr.pssl == pss
                        select rr).FirstOrDefault();

            return r;
        }
Exemplo n.º 8
0
        public Person getPersonByEmail(string email)
        {
            DBEntities db = new DBEntities();
            Person r = new Person();

            r = (from rr in db.People
                 where rr.Email == email
                 select rr).FirstOrDefault();

            return r;
        }
Exemplo n.º 9
0
        public Person getPersonBySurname(string surname)
        {
            DBEntities db = new DBEntities();
            Person r = new Person();

            r = (from rr in db.People
                 where rr.Surname == surname
                 select rr).First();
            //if(r.Any())

            return r;
        }
Exemplo n.º 10
0
        public string GetDataByEmail(string email)
        {
            //return string.Format("You entered: {0}", id);
            //TODO zwracanie obiektu zawierajacego dane

            SDOModelMethods sdomm = new SDOModelMethods();
            Person p = new Person();
            try
            {
                p = sdomm.getPersonByEmail(email);
            }
            catch (Exception e)
            {
                return e.Message;
            }
            //return string.Format("{0} {1}, {2}, student: {3}", p.Name, p.Surname, p.Email, p.Student);
            if (p != null)
            {
                return string.Format("{0}%%%{1}%%%{2}%%%{3}%%%{4}", p.Name, p.Surname, p.Email, p.pssl, p.Student);
            }
            else
            {
                return "";
            }
        }
Exemplo n.º 11
0
        public string GetDataBySurname(string surname)
        {
            //return string.Format("You entered: {0}", id);
            //TODO zwracanie obiektu zawierajacego dane

            SDOModelMethods sdomm = new SDOModelMethods();
            Person p = new Person();
            try
            {
                p = sdomm.getPersonBySurname(surname);
            }
            catch (Exception e)
            {
                return e.Message;
            }
            return string.Format("{0}%%%{1}%%%{2}%%%{3}%%%{4}%%%{5}", p.Name, p.Surname, p.Email, p.pssl, p.Student, p.Id);
        }