예제 #1
0
        /// <summary>
        /// Represent a method for creating travel data
        /// </summary>
        /// <param name="_title">Represent the Title (string) of the travel</param>
        /// <param name="_city">Represent the By (string) of the travel</param>
        /// <param name="_startDate">Represent the Startdato (datetime) of the travel</param>
        /// <param name="_endDate">Represent the Slutdato (datetime) of the travel</param>
        /// <param name="_price">Represent the Pris (int) of the travel</param>
        /// <param name="_maxparticipant">Represent the MaxAntal (string) of the travel</param>
        /// <param name="_describtion">Represent the Beskrivelse (string) of the travel</param>
        public void CreateTravel(string _title, string _city, DateTime _startDate, DateTime _endDate, int _price, string _maxparticipant, string _describtion)
        {
            //Represent a object of VikingRejserEntities called _context
            VikingRejserEntities _context = new VikingRejserEntities();

            Rejsearrangementer _travel = new Rejsearrangementer
            {
                //Represent the Title (string) of the travel
                Title = _title,

                //Represent the By (string) of the travel
                By = _city,

                //Represent the Startdato (datetime) of the travel
                Stardato = _startDate,

                //Represent the Slutdato (datetime) of the travel
                Slutdato = _endDate,

                //Represent the Pris (int) of the travel
                Pris = _price,

                //Represent the MaxAntal (string) of the travel
                MaxAntal = _maxparticipant,

                //Represent the Beskrivelse (string) of the travel
                Beskrivelse = _describtion
            };

            _context.Rejsearrangementers.Add(_travel);

            _context.SaveChanges();
        }
예제 #2
0
        /// <summary>
        /// Represent a method for editing travel data
        /// </summary>
        /// <param name="_id">Represnt the unique id (int) of each travel</param>
        /// <param name="_title">Represent the Title (string) of the travel</param>
        /// <param name="_city">Represent the By (string) of the travel</param>
        /// <param name="_startDate">Represent the Startdato (datetime) of the travel</param>
        /// <param name="_endDate">Represent the Slutdato (datetime) of the travel</param>
        /// <param name="_price">Represent the Pris (int) of the travel</param>
        /// <param name="_maxparticipant">Represent the MaxAntal (string) of the travel</param>
        /// <param name="_describtion">Represent the Beskrivelse (string) of the travel</param>
        public void EditTravel(int _id, string _title, string _city, DateTime _startDate, DateTime _endDate, int _price, string _maxparticipant, string _describtion)
        {
            //Represent a object of VikingRejserEntities called _context
            VikingRejserEntities context = new VikingRejserEntities();

            Rejsearrangementer travel = context.Rejsearrangementers.First(i => i.Id == _id);

            //Represent the Title (string) of the travel
            travel.Title = _title;

            //Represent the By (string) of the travel
            travel.By = _city;

            //Represent the Startdato (datetime) of the travel
            travel.Stardato = _startDate;

            //Represent the Slutdato (datetime) of the travel
            travel.Slutdato = _endDate;

            //Represent the Pris (int) of the travel
            travel.Pris = _price;

            //Represent the MaxAntal (string) of the travel
            travel.MaxAntal = _maxparticipant;

            //Represent the Beskrivelse (string) of the travel
            travel.Beskrivelse = _describtion;

            context.SaveChanges();
        }