// GET: Student
        public string GetEvents(string jsonString)
        {
            var Id     = JsonConvert.DeserializeObject <ID>(jsonString);
            var person = db.GetPerson(Id.Id);

            if (person.Status == "Nauczyciel")
            {
                IEnumerable <EventViewModel> events = db.GetEventsForTeaher(person).Select(p =>
                                                                                           new EventViewModel()
                {
                    Category    = p.Category,
                    Description = p.Description,
                    Title       = p.Title,
                    Data        = p.Data,
                    EndDate     = p.EndData
                });
                return(JsonConvert.SerializeObject(events));
            }
            else if (person.Status == "Uczeń")
            {
                IEnumerable <EventViewModel> events = db.GetEventsForStudent(person).Select(p =>
                                                                                            new EventViewModel()
                {
                    Category    = p.Category,
                    Description = p.Description,
                    Title       = p.Title,
                    Data        = p.Data,
                    EndDate     = p.EndData
                });
                return(JsonConvert.SerializeObject(events));
            }

            return("");
        }
示例#2
0
        public string AddSubject(string jsonString = "{\"id_class\":\"2\",\"id_group\":\"\",\"id_teaher\":\"1\",\"name\":\"Francuski\"}")
        {
            AddSubjectPostViewModel addSubject = JsonConvert.DeserializeObject <AddSubjectPostViewModel>(jsonString);
            Subject s = new Subject()
            {
                Person                        = db.GetPerson(addSubject.ID_Teaher),
                Group                         = addSubject.ID_Group != null?db.GetGroup(addSubject.ID_Group) : null,
                                        Class = db.GetClass(addSubject.ID_Class),
                                        Name  = addSubject.Name
            };

            db.AddSubject(s);
            return("Dodano");
        }
示例#3
0
        // GET: Student
        public string GetPresence(string jsonString)
        {
            var Id     = JsonConvert.DeserializeObject <ID>(jsonString);
            var person = db.GetPerson(Id.Id);
            IEnumerable <GetPresenceViewModel> presenceToSend = person.Presence.Select(p => new GetPresenceViewModel()
            {
                Status      = p.Status,
                Date        = p.Lesson.Date,
                Time        = p.Lesson.Hour,
                NameTeacher = p.Lesson.Person.FirstName + " " + p.Lesson.Person.LastName,
                Subject     = p.Lesson.Subject.Name
            });

            return(JsonConvert.SerializeObject(presenceToSend));
        }
        public string Index(string jsonString)
        {
            ChangePasswordViewModel changePasswordWiev = JsonConvert.DeserializeObject <ChangePasswordViewModel>(jsonString);
            var login = db.GetPerson(changePasswordWiev.Id).Login;

            if (login != null)
            {
                if (changePasswordWiev.Password == changePasswordWiev.ConfirmedPassword)
                {
                    login.Password = PasswordManager.GetMd5Hash(changePasswordWiev.Password);
                    db.ChangePassword(login);
                    return("Zmieniono Hasło");
                }
                else
                {
                    return("Hasła nie zgadzają się");
                }
            }
            return("Nie zmieniono hasła");
        }