Ejemplo n.º 1
0
        /// <summary>
        /// Add the institution. 
        /// </summary>
        /// <param name="sender">The sender of the events</param>
        /// <param name="e">The args of the event</param>
        protected void AddButton_Click(object sender, EventArgs e)
        {
            Extensions.SqlOperation operation = () =>
            {
                var institutionsDAO = new InstitutionsDAO();

                var departments = (from ListItem department in DepartmentList.Items select new Department {Name = department.Text}).ToList();

                //Intantiate institution
                var language = new Language { Name = LanguageList.SelectedValue };
                var continent = new Continent { Name = ContinentList.SelectedValue };
                var country = new Country { Name = CountryList.SelectedValue, Continent = continent };
                var institution = new Institution(-1,
                                                            NameText.Text,
                                                            DescriptionText.Text,
                                                            CityText.Text,
                                                            InterestText.Text,
                                                            language,
                                                            country,
                                                            departments,
                                                            false);
                var institutionId = institutionsDAO.AddInstitution(institution);
                Response.Redirect("ShowInstitution.aspx?institution=" + institutionId);
            };
            this.Verified(operation, ErrorLabel);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns all the countries of the specified continent of the database. 
        /// </summary>
        /// <param name="continent">The contient to search country for</param>
        /// <returns>a List containing all the countries of the specified continent</returns>
        public List<Country> GetCountries(Continent continent)
        {
            Logger.Debug("Search countries of {0}", continent.Name);

            var countries = new List<Country>();

            var connection = DBManager.GetInstance().GetNewConnection();

            var parameters = new NameValueCollection
            {
                {"@continent", continent.Name}
            };

            using (var reader = DBUtils.ExecuteQuery("SELECT name FROM [Country] WHERE continentName = @continent", connection, IsolationLevel.ReadUncommitted, parameters))
            {
                while (reader.Read())
                {
                    countries.Add(BindCountry(reader));
                }
            }

            connection.Close();

            Logger.Debug("Found {0} countries", countries.Count);

            return countries;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Save the changes. 
        /// </summary>
        /// <param name="sender">The sender of the events</param>
        /// <param name="e">The args of the event</param>
        protected void EditButton_Click(object sender, EventArgs e)
        {
            Extensions.SqlOperation operation = () =>
            {
                var tr = (int) ViewState["transaction"];
                var transaction = (SqlTransaction) Session["transaction" + tr];
                var connection = (SqlConnection) Session["connection" + tr];

                var institutionId = Request.QueryString["institution"].ToInt();
                var institutionsDAO = new InstitutionsDAO();

                //Instantiate and fill department list
                var departments = (from ListItem department in DepartmentList.Items select new Department {Name = department.Text}).ToList();

                //Intantiate institution
                var language = new Language { Name = LanguageList.SelectedValue };
                var continent = new Continent { Name = ContinentList.SelectedValue };
                var country = new Country { Name = CountryList.SelectedValue, Continent = continent };
                var institution = new Institution(institutionId,
                                                            NameText.Text,
                                                            DescriptionText.Text,
                                                            CityText.Text,
                                                            InterestText.Text,
                                                            language,
                                                            country,
                                                            departments,
                                                            false);

                institutionsDAO.UpdateInstitution(institution, transaction);

                transaction.Commit();
                connection.Close();

                Response.Redirect("ShowInstitution.aspx?institution=" + institutionId);
            };
            this.Verified(operation, ErrorLabel);
        }