Ejemplo n.º 1
0
        public ViewResult Edit(int cityId)
        {
            ViewData["CountriesList"] = GetCountriesList();
            City city = GetHelper <City> .GetById(Globals.CITIES_API_LINK, cityId);

            return(View("Edit", city));
        }
Ejemplo n.º 2
0
        public ViewResult Edit(int subjectId)
        {
            ViewData["TeacherList"] = GetTeachersList();
            Subject subject = GetHelper <Subject> .GetById(Globals.SUBJECTS_API_LINK, subjectId);

            return(View("EditSubject", subject));
        }
Ejemplo n.º 3
0
        public ViewResult Edit(int attractionId)
        {
            ViewData["CitiesList"] = GetCityList();
            Attraction attraction = GetHelper <Attraction> .GetById(Globals.ATTRACTION_API_LINK, attractionId);

            return(View("Edit", attraction));
        }
Ejemplo n.º 4
0
        public ActionResult EditAttraction(Attraction attraction)
        {
            City city = GetHelper <City> .GetById(Globals.CITIES_API_LINK, attraction.city.id);

            Country country = GetHelper <Country> .GetById(Globals.COUNTRIES_API_LINK, city.country.id);

            Attraction updatedAttraction = new Attraction()
            {
                id      = attraction.id,
                name    = attraction.name,
                address = attraction.address,
                type    = attraction.type,
                city    = new City
                {
                    id      = city.id,
                    name    = city.name,
                    country = new Country
                    {
                        id   = country.id,
                        name = country.name
                    }
                }
            };

            UpdateHelper <Attraction> .UpdateEntity(Globals.ATTRACTION_API_LINK, updatedAttraction);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public ActionResult EditSubject(Subject subject)
        {
            Teacher teacher = GetHelper <Teacher> .GetById(Globals.TEACHERS_API_LINK, subject.teacher.id);

            subject.teacher = teacher;
            UpdateHelper <Subject> .UpdateEntity(Globals.SUBJECTS_API_LINK, subject);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 6
0
        public ActionResult EditClass(Class @class)
        {
            Class oldClass = GetHelper <Class> .GetById(Globals.CLASSES_API_LINK, @class.id);

            var oldName = oldClass.name;

            oldClass.name = @class.name;
            UpdateHelper <Class> .UpdateEntity(Globals.CLASSES_API_LINK, oldClass);

            TempData["message"] = "Pomyślnie dokonano edycji klasy " + oldName + " o id: " + @class.id;
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 7
0
        public ActionResult RemoveStudentFromClass(int classId, int studentId)
        {
            GetHelper <Class> .Remove(Globals.CLASSES_REMOVE_API_LINK, classId, studentId);

            var className = GetHelper <Class> .GetById(Globals.CLASSES_API_LINK, classId).name;

            Student student = GetHelper <Student> .GetById(Globals.STUDENTS_API_LINK, studentId);

            var studentName = student.forename + " " + student.surname;

            TempData["message"] = "Pomyślnie usunięto studenta " + studentName + " z klasy " + className;

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 8
0
        public ActionResult DeleteClass(int classId)
        {
            Class @class = GetHelper <Class> .GetById(Globals.CLASSES_API_LINK, classId);

            foreach (Student student in @class.students)
            {
                GetHelper <Class> .Remove(Globals.CLASSES_REMOVE_API_LINK, classId, student.id);
            }

            DeleteHelper.DeleteEntity(Globals.CLASSES_API_LINK, classId);

            TempData["message"] = "Pomyślnie usunięto klasę " + @class.name + " o id: " + classId;
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 9
0
        public ActionResult AddStudentToClass(int classId, int studentId)
        {
            GetHelper <Class> .Add(Globals.CLASSES_ADD_API_LINK, classId, studentId);

            var className = GetHelper <Class> .GetById(Globals.CLASSES_API_LINK, classId).name;

            Student student = GetHelper <Student> .GetById(Globals.STUDENTS_API_LINK, studentId);

            var studentName = student.forename + " " + student.surname;

            TempData["message"] = "Pomyślnie dodano studenta " + studentName + " do klasy " + className;

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 10
0
        public ActionResult SelectAttractions(City city)
        {
            city = GetHelper <City> .GetById(Globals.CITIES_API_LINK, city.id);

            Location location = new Location()
            {
                Address    = Request.Form["address"],
                Langtitude = float.Parse(Request.Form["lang"]),
                Longtitude = float.Parse(Request.Form["long"])
            };

            ViewData["Location"]       = location;
            ViewData["AttractionList"] = GetAttractionList(city);
            return(View());
        }
Ejemplo n.º 11
0
        public ActionResult SelectCity(Country country)
        {
            country = GetHelper <Country> .GetById(Globals.COUNTRIES_API_LINK, country.id);

            Location location = new Location()
            {
                Address    = Request.Form["address"],
                Langtitude = float.Parse(Request.Form["lang"]),
                Longtitude = float.Parse(Request.Form["long"])
            };

            ViewData["Location"] = location;
            ViewData["CityList"] = GetCityList(country);
            return(View());
        }
Ejemplo n.º 12
0
        public ActionResult AddCity(City city)
        {
            Country country = GetHelper <Country> .GetById(Globals.COUNTRIES_API_LINK, city.country.id);

            city.country = country;

            City newCity = new City
            {
                name    = city.name,
                country = new Country
                {
                    id   = country.id,
                    name = country.name
                }
            };

            PostHelper <City> .PostEntity(Globals.CITIES_API_LINK, newCity);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 13
0
        private List <Location> SetLocationList(string[] ids)
        {
            List <Location> locations = new List <Location>();

            foreach (string id in ids)
            {
                Attraction attraction = GetHelper <Attraction> .GetById(Globals.ATTRACTION_API_LINK, int.Parse(id));

                Location location = new Location();
                location.Address = attraction.city.name + " " + attraction.address;

                DataTable locationDataTable = GetLatAndLongOfStreet(getRequestUrl(location.Address));
                location.Longtitude = float.Parse(locationDataTable.Rows[0]["Longtitude"].ToString(), CultureInfo.InvariantCulture);
                location.Langtitude = float.Parse(locationDataTable.Rows[0]["Latitude"].ToString(), CultureInfo.InvariantCulture);

                locations.Add(location);
            }

            return(locations);
        }
Ejemplo n.º 14
0
        public ActionResult EditCity(City city)
        {
            Country country = GetHelper <Country> .GetById(Globals.COUNTRIES_API_LINK, city.country.id);

            city.country = country;

            City updatedCity = new City
            {
                id      = city.id,
                name    = city.name,
                country = new Country
                {
                    id   = country.id,
                    name = country.name
                }
            };

            UpdateHelper <City> .UpdateEntity(Globals.CITIES_API_LINK, updatedCity);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 15
0
 private void SetClassName(int classId)
 {
     ViewData["className"] = GetHelper <Class> .GetById(Globals.CLASSES_API_LINK, classId).name;
 }
Ejemplo n.º 16
0
        public ActionResult ViewAttractions(int cityId)
        {
            City cityGet = GetHelper <City> .GetById(Globals.CITIES_API_LINK, cityId);

            return(View("ViewAttractions", cityGet.attractions));
        }
Ejemplo n.º 17
0
        public ViewResult Edit(int countryId)
        {
            Country country = GetHelper <Country> .GetById(Globals.COUNTRIES_API_LINK, countryId);

            return(View("Edit", country));
        }
Ejemplo n.º 18
0
        public ActionResult ViewCities(int countryId)
        {
            Country countryGet = GetHelper <Country> .GetById("countries", countryId);

            return(View("ViewCities", countryGet.cities));
        }
Ejemplo n.º 19
0
        public ViewResult Edit(int studentId)
        {
            Student student = GetHelper <Student> .GetById(Globals.STUDENTS_API_LINK, studentId);

            return(View("EditStudent", student));
        }
Ejemplo n.º 20
0
        public ViewResult Edit(int classId)
        {
            Class @class = GetHelper <Class> .GetById(Globals.CLASSES_API_LINK, classId);

            return(View("EditClass", @class));
        }
Ejemplo n.º 21
0
        public ViewResult Edit(int teacherId)
        {
            Teacher teacher = GetHelper <Teacher> .GetById(Globals.TEACHERS_API_LINK, teacherId);

            return(View("EditTeacher", teacher));
        }