protected void btnPlaatsHulpvraag_Click(object sender, EventArgs e)
        {
            string message = string.Empty;

            // Get values of page
            string title = inputTitel.Value;
            string desc = inputBeschrijving.Value;
            string location = inputLocatie.Value;
            //List<Skilldetails> skills = new List<Skilldetails>();
            //foreach (ListItem item in select_skills_output.Items)
            //{
            //    Skilldetails sk = new Skilldetails();
            //    sk.Name = item.Value;
            //    skills.Add(sk);
            //}
            DateTime startDate = new DateTime(Convert.ToInt32(input_startdate_3.Value),
                Convert.ToInt32(input_startdate_2.Value), Convert.ToInt32(input_startdate_1.Value),
                Convert.ToInt32(input_startdate_4.Value), Convert.ToInt32(input_startdate_5.Value), 0);
            DateTime endDate = new DateTime(Convert.ToInt32(input_einddate_3.Value),
                Convert.ToInt32(input_einddate_2.Value), Convert.ToInt32(input_einddate_1.Value),
                Convert.ToInt32(input_einddate_4.Value), Convert.ToInt32(input_einddate_5.Value), 0);

            //TODO  bool checkSucces = Admin_Layer.Check.QuestionDetails(qd, string errorMessage );

            // Create new question details and fill properties
            Questiondetails qd = new Questiondetails();
            qd.Title = title;
            qd.Description = desc;
            qd.PostDate = DateTime.Now;
            qd.Skills = selected_skills.Select(i => i.Name).ToList();
            qd.Location = location;
            qd.StartDate = startDate;
            qd.EndDate = endDate;
            qd.Urgent = inputUrgentie.Checked;
            qd.Status = "Open";

            // Place question
            if (!GUIHandler.Place(qd, out message))
            {
                ShowErrorMessage(message);
                return;
            }
            else
            {
                // Redirect to profiel.aspx if question was placed successfully
                Response.Redirect("profiel.aspx", false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// check the question details for correct input
        /// </summary>
        /// <param name="qd">question details object</param>
        /// <param name="message">error output message</param>
        /// <returns>succes boolean</returns>
        public static bool QuestionDetails(Questiondetails qd, out string message)
        {
            if (!Check.checkIfFilledIn(qd.Title))
            {
                message = "Titel is niet ingevuld!";
                return false;
            }
            if (!Check.checkIfFilledIn(qd.Description))
            {
                message = "Beschrijving is niet ingevuld!";
                return false;
            }
            if (!Check.checkIfFilledIn(qd.Location))
            {
                message = "Locatie is niet ingevuld!";
                return false;
            }
            if (checkSkillCountIsEmpty(qd.Skills.Count)) //if 0 then true
            {
                message = "Geen skills toegevoegd!";
                return false;
            }

            bool isStartDateNull = true;
            bool isEndDateNull = true;
            if (qd.StartDate != null)
            {
                if ( ((DateTime)qd.StartDate).Subtract(DateTime.Now) < TimeSpan.Zero)
                {
                message = "De begintijd is al geweest!";
                return false;
                }
                isStartDateNull = false;
            }
            if (qd.StartDate != null)
            {
                if ( ((DateTime)qd.EndDate).Subtract(DateTime.Now) < TimeSpan.Zero)
                {
                message = "De eindtijd is al geweest!";
                return false;
                }
                isEndDateNull = false;
            }
            if (!isEndDateNull && !isStartDateNull)
            {
                if ((DateTime)qd.StartDate < (DateTime)qd.EndDate)
                {
                    message = "De einddatum mag niet eerder zijn dan/gelijk zijn aan de startdatum!";
                    return false;
                }
            }
            message = "Vraag succesvol aangemaakt";
            return true;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Places a question
 /// </summary>
 /// <param name="question">The question details</param>
 /// <param name="message">The message of the error</param>
 /// <returns>Success</returns>
 public bool Place(Questiondetails question, out string message)
 {
     //Check for rights
     if (MainUser.Role == Accounttype.Hulpbehoevende)
     {
         //TODO: Validate details
         //Place question
         Question q = new Question(0, MainUser.ID, question.Title, question.StartDate, question.EndDate, question.Description, question.Urgent, question.Location, question.AmountAccs, question.Skills, new List<int>());
         q.Create();
         message = "Vraag gepost!";
         return true;
     }
     else
     {
         message = "U hebt niet de rechten om een vraag te plaatsen";
         return false;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Edits a question
 /// </summary>
 /// <param name="question">The question details</param>
 /// <param name="questionIndex">The index of the question as loaded in the list</param>
 /// <param name="message">The message of the error</param>
 /// <returns>Success</returns>
 public bool Edit(Questiondetails question, int questionIndex, out string message)
 {
     //Check for rights
     if (LoadedQuestions[questionIndex].PosterID == MainUser.ID)
     {
         //TODO: Validate details
         //Edit question
         Question q = new Question(LoadedQuestions[questionIndex].PostID, MainUser.ID, question.Title, question.StartDate, question.EndDate, question.Description, question.Urgent, question.Location, question.AmountAccs, question.Skills, LoadedQuestions[questionIndex].Volunteers);
         q.Update();
         message = "Vraag succesvol aangepast!";
         return true;
     }
     else
     {
         message = "U hebt niet de rechten om deze vraag aan te passen";
         return false;
     }
 }