protected void developing(object sender, EventArgs e)
        {
            //Get the query string parameters.
            string projectTitle = Session["ProjectTitle"].ToString();
            int projectCode = Int32.Parse(Session["ProjectCode"].ToString());

            //Create a project and look for the one we are being asked.
            ProjectBE project = new ProjectBE();
            project.Code = projectCode;
            project = project.getByCode();

            //We get the user who wants to develop.
            UserBE user = new UserBE();
            user.Email = Session["UserEmail"].ToString();
            user = user.getUserByEmail();

            DateTime date = DateTime.Now;
            String gitUrl = "none";
            int votes = 0;

            DevelopmentBE develop = new DevelopmentBE(project, user, date, gitUrl, votes);

            develop.create();

            developFeedback.ForeColor = System.Drawing.Color.Red;
            developFeedback.Text = "Accepted";
        }
Esempio n. 2
0
        //Getter for all the users.
        public List<UserBE> getAllUsers()
        {
            List<UserBE> users = new List<UserBE>();

            SqlConnection c = new SqlConnection(connection);
            c.Open();

            SqlCommand com = new SqlCommand("SELECT * FROM Users", c);

            SqlDataReader dr = com.ExecuteReader();

            while (dr.Read())
            {
                UserBE user = new UserBE();
                user.Name = dr["name"].ToString();
                user.LastName = dr["last_name"].ToString();
                user.Email = dr["email"].ToString();
                user.Nickname = dr["nickname"].ToString();
                user.Password = dr["password"].ToString();
                user.Credit = Int32.Parse(dr["credits"].ToString());
                users.Add(user);
            }

            c.Close();

            return users;
        }
Esempio n. 3
0
 // /////////////////////////////////////////////////////////////////////
 // Constructors ////////////////////////////////////////////////////////
 // /////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Default Constructor.
 /// Creates a new comment business entity with "empty" values.
 /// </summary>
 public CommentBE()
 {
     writer = new UserBE();
     project = new ProjectBE();
     date = DateTime.Now;
     content = "";
 }
Esempio n. 4
0
 /// <summary>
 /// Copy Constructor.
 /// Creates a new contribution business entity by copying the fields
 /// of another contribution BE.
 /// </summary>
 /// <param name="contribution">The source contribution.</param>
 public ContributionBE(ContributionBE contribution)
 {
     this.contributor = contribution.contributor;
     this.project = contribution.project;
     this.amount = contribution.amount;
     this.date = contribution.date;
 }
Esempio n. 5
0
 /* ****************************************************************** */
 /* Constructors                                                       */
 /* ****************************************************************** */
 public ContributionBE()
 {
     contributor = null;
     project = null;
     amount = 0.0f;
     date = new DateTime();
 }
Esempio n. 6
0
 // /////////////////////////////////////////////////////////////////////
 // Constructors ////////////////////////////////////////////////////////
 // /////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Default Constructor.
 /// Creates a new contribution business entity with "empty" values.
 /// </summary>
 public ContributionBE()
 {
     contributor = new UserBE();
     project = new ProjectBE();
     amount = 0;
     date = DateTime.Now;
 }
Esempio n. 7
0
 /// <summary>
 /// Auxiliary Constructor.
 /// Creates a new contribution business entity filling the fields
 /// with the provided ones.
 /// </summary>
 /// <param name="contributor">The user that performed the contribution.</param>
 /// <param name="project">The destination project of the contribution</param>
 /// <param name="amount">The amount of credits contributed.</param>
 /// <param name="date">The date when the contribution was made.</param>
 public ContributionBE(UserBE contributor, ProjectBE project, int amount, DateTime date)
 {
     this.contributor = contributor;
     this.project = project;
     this.amount = amount;
     this.date = date;
 }
Esempio n. 8
0
        /* Deletes the message for the specified user. If both users have
         * deleted it, it is removed from database. */
        public bool deleteMessage(MessageBE m, UserBE u = null)
        {
            bool deleted = false;

            bool delSend = false, delAddr = false;
            String sender = "", addressee = "";

            SqlConnection c = new SqlConnection(connection);
            c.Open();

            SqlCommand com = new SqlCommand("SELECT sender, addressee, " +
                "deleted_sender, deleted_reader FROM Messages WHERE code = " + m.code.ToString() + "', 0)", c);

            SqlDataReader dr = com.ExecuteReader();

            while (dr.Read())
            {
                sender = dr["sender"].ToString();
                addressee = dr["addressee"].ToString();
                delSend = bool.Parse(dr["deleted_sender"].ToString());
                delAddr = bool.Parse(dr["deleted_reader"].ToString());
            }

            if (u.Email == sender)
            {
                m.DelSender = true;
                deleted = true;

                if (delAddr == true)
                {
                    com = new SqlCommand("DELETE FROM Messages WHERE code = " + m.code.ToString() + "', 0)", c);
                    com.ExecuteNonQuery();
                }
                else
                {
                    com = new SqlCommand("UPDATE Messages SET deleted_sender = TRUE WHERE code = " + m.code.ToString() + "', 0)", c);
                    com.ExecuteNonQuery();
                }
            }
            else if (u.Email == addressee)
            {
                m.DelAddressee = true;
                deleted = true;

                if (delSend == true)
                {
                    com = new SqlCommand("DELETE FROM Messages WHERE code = " + m.code.ToString() + "', 0)", c);
                    com.ExecuteNonQuery();
                }
                else
                {
                    com = new SqlCommand("UPDATE Messages SET deleted_reader = TRUE WHERE code = " + m.code.ToString() + "', 0)", c);
                    com.ExecuteNonQuery();
                }
            }

            c.Close();

            return deleted;
        }
Esempio n. 9
0
        protected void createUserClick(object sender, EventArgs e)
        {
            Button clickedButton = (Button)sender;
            String name = "", lastName = "", userName = "", password = "", email = "", gender = "";

            name = Name.Text;
            lastName = LastName.Text;
            userName = UserNameBox.Text;
            password = Password.Text;
            email = Email.Text;
            gender = MaleFemale.SelectedValue.ToString();

            UserBE usuario = new UserBE(name, 0, lastName, email, userName, password);
            resultLabel.Text = usuario.create();

            /* If the user is created successfully, the DB returns this string.
             Only in this condition we are going to upload the file. */
            if (resultLabel.Text == "The user has been succesfully created!" && AsyncFileUpload1.FileName!="")
            {
                string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
                AsyncFileUpload1.SaveAs(Server.MapPath("Uploads/") + usuario.Nickname + "_pict.jpg");
                lblMesg.Text = "File Uploaded successfully";
                lblMesg.ForeColor = System.Drawing.Color.Green;
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Auxiliary Constructor.
 /// Creates a new comment business entity initializing its fields with
 /// the provided ones.
 /// </summary>
 /// <param name="writer">The writer of the comment.</param>
 /// <param name="project">The project which is being commented.</param>
 /// <param name="creation_date">The date when the comment was submitted.</param>
 /// <param name="content">The comment body.</param>
 public CommentBE(UserBE writer, ProjectBE project, DateTime creation_date,
     string content)
 {
     this.writer = writer;
     this.project = project;
     this.date = creation_date;
     this.content = content;
 }
Esempio n. 11
0
 /// <summary>
 /// Copy Constructor.
 /// Creates a new development business entity by copying the fields
 /// of another development BE.
 /// </summary>
 /// <param name="development"></param>
 public DevelopmentBE(DevelopmentBE development)
 {
     this.project = development.project;
     this.user = development.user;
     this.date = development.date;
     this.gitBranch = development.gitBranch;
     this.ups = development.ups;
 }
Esempio n. 12
0
 /// <summary>
 /// Auxiliary Constructor.
 /// Creates a new development business entity initializing its fields with
 /// the provided ones.
 /// </summary>
 /// <param name="project">The project of the development.</param>
 /// <param name="user">The user that makes the development.</param>
 /// <param name="date">The date when the development was submitted.</param>
 /// <param name="gitBranch">The git branch URL of the development.</param>
 /// <param name="ups">The number of upvotes (positive reviews).</param>
 public DevelopmentBE(ProjectBE project, UserBE user, DateTime date, string gitBranch, int ups)
 {
     this.project = project;
     this.user = user;
     this.date = date;
     this.gitBranch = gitBranch;
     this.ups = ups;
 }
Esempio n. 13
0
 public CommentBE()
 {
     code = "";
     writer = new UserBE();
     project = new ProjectBE();
     title = "";
     content = "";
     projectAssessment = -1;
 }
Esempio n. 14
0
        protected void send_Message(object sender, EventArgs e)
        {
            bool correct = true;

            if (textuserdest.Text.Length == 0)
            {
                userFeedback.Visible = true;
                correct = false;
            }
            else
            {
                UserBE user1 = new UserBE("", 0, "", "", textuserdest.Text, "");
                UserBE dest = new UserBE(user1.getUserByNick());

                if (dest.Email == "")
                {
                    correct = false;
                    existsFeedback.Visible = true;
                }
            }

            if (textsubject.Text.Length == 0)
            {
                subjectFeedback.Visible = true;
                correct = false;
            }

            if (textmessage.Text.Length == 0)
            {
                messageFeedback.Visible = true;
                correct = false;
            }
            else if (textmessage.Text.Length > 1000)
            {
                lengthFeedback.Visible = true;
                lengthFeedback.Text = "The message is too long! Delete " + (textmessage.Text.Length - 1000).ToString() + " characters.";
                correct = false;
            }
            if (correct)
            {
                String subject = textsubject.Text;
                String message = textmessage.Text;
                DateTime date = DateTime.Now;

                UserBE user1 = new UserBE("", 0, "", "", Session["UserNickname"].ToString(), "");
                UserBE sender1 = new UserBE(user1.getUserByNick());

                user1 = new UserBE("", 0, "", "", textuserdest.Text, "");
                UserBE addressee = new UserBE(user1.getUserByNick());

                MessageBE sndMessage = new MessageBE(sender1, addressee, date, subject, message);

                sndMessage.sendMessage();
                Response.Redirect("ProfileMessages.aspx?Box=Out");
            }
        }
Esempio n. 15
0
 /* ****************************************************************** */
 /* Constructors                                                       */
 /* ****************************************************************** */
 public NewsBE()
 {
     title = "";
     content = "";
     author = new UserBE();
     code = -1;
     publicationDate = new DateTime();
     topic = new DevelopmentBE();
     project = new ProjectBE();
 }
        protected void gridResults_RowCommand(Object sender, GridViewCommandEventArgs e)
        {
            // Convert the row index stored in the CommandArgument
            // property to an Integer.
            int index = Convert.ToInt32(e.CommandArgument);

            // Get the last name of the selected author from the appropriate
            // cell in the GridView control.
            GridViewRow selectedRow = gridResults.Rows[index];
            TableCell codeCell = selectedRow.Cells[6];
            int code = int.Parse(codeCell.Text);

            MessageBE message = MessageDAC.getMessage(code);

            if (e.CommandName == "View")
            {
                Cabecera.Visible = true;
                Cabecera.Text = "Selected Message Preview:";
                Emisor.Visible = true;

                if (Request.QueryString["Box"] == "Out")
                    Emisor.Text = "To:  " + message.Addressee.Nickname;
                else
                    Emisor.Text = "From:  " + message.Sender.Nickname;

                Fecha.Visible = true;
                Fecha.Text = "Date:  " + message.Date.ToString();
                Asunto.Visible = true;
                Asunto.Text = message.Subject;
                Texto.Visible = true;
                Texto.Text = message.Message;

                if (!message.Read && Request.QueryString["Box"] == "In")
                {
                    message.openMessage();
                    Load_Grid();
                }
            }

            if (e.CommandName == "Delete")
            {
                UserBE user1 = new UserBE("", 0, "", "", Session["UserNickname"].ToString(), "");
                UserBE currentUser = new UserBE(user1.getUserByNick());
                message.removeMessage(currentUser);

                if (Request.QueryString["Box"] == "Out")
                {
                    Response.Redirect("ProfileMessages.aspx?Box=Out");
                }
                else
                {
                    Response.Redirect("ProfileMessages.aspx?Box=In");
                }
            }
        }
Esempio n. 17
0
        /*
         * Default constructor. We do not receive a commentAssesment because
         * it is a new comment so it can not have assessments before being created.
         * The date is also not necesary. We will assign it.
         */
        public CommentBE(UserBE writer, ProjectBE project, string title, 
            string content, int projectAssessment)
        {
            code = generateCode();

                this.writer = writer;
                this.project = project;
                this.title = title;
                this.content = content;
                this.projectAssessment = projectAssessment;
        }
Esempio n. 18
0
        public static void loadCookie(HttpCookie userCookie)
        {
            UserBE user1 = new UserBE("", 0, "", "", userCookie.Value, "");
            UserBE user = new UserBE(user1.getUserByNick());

            HttpContext.Current.Session["UserNickname"] = user.Nickname;
            HttpContext.Current.Session["UserName"] = user.Name;
            HttpContext.Current.Session["UserLastname"] = user.LastName;
            HttpContext.Current.Session["UserEmail"] = user.Email;
            HttpContext.Current.Session["UserCredit"] = user.Credit;
            HttpContext.Current.Session["UserProfpict"] = user.ProfilePicture;
        }
Esempio n. 19
0
 public NewsBE(string title, string content, int code,
     UserBE author, DateTime publicationDate,
     DevelopmentBE topic, ProjectBE project)
 {
     this.code = code;
     this.title = title;
     this.content = content;
     this.author = author;
     this.publicationDate = publicationDate;
     this.topic = topic;
     this.project = project;
 }
Esempio n. 20
0
 /* ****************************************************************** */
 /* Constructors                                                       */
 /* ****************************************************************** */
 public ProjectBE()
 {
     title = "";
     description = "";
     creator = null;
     code = "";
     creationDate = new DateTime();
     expirationDate = new DateTime();
     state = ProjectState.Closed;
     credit = 0.0f;
     lastVersion = new DateTime();
     gitDir = "";
 }
Esempio n. 21
0
        protected void create_News(object sender, EventArgs e)
        {
            NewsBE news = new NewsBE();
            news.Title = TitleTB.Text;
            if (Request.QueryString["code"]!=null) news.Code = Int32.Parse(Request.QueryString["code"]);
            news.Content = ContentTB.Text;
            news.PublicationDate = DateTime.Now;
            UserBE user1 = new UserBE("", 0, "", "", Session["UserNickname"].ToString(), "");
            UserBE author = new UserBE(user1.getUserByNick());
            news.Author = author;

            news.create();
            Response.Redirect("NewsAdmin.aspx");
        }
Esempio n. 22
0
        /// <summary>
        /// Auxiliary Constructor.
        /// Creates a new commet filling all the fields with the specified values.
        /// </summary>
        /// <param name="sender">The user who sends the message.</param>
        /// <param name="addressee">The user who will receive the message.</param>
        /// <param name="date">The date when the message is sent.</param>
        /// <param name="subject">The message subject.</param>
        /// <param name="message">The message body.</param>
        public MessageBE(UserBE sender, UserBE addressee, DateTime date,
            string subject, string message)
        {
            this.messageDAC = new MessageDAC();

            this.read = false;
            this.delAddressee = false;
            this.delSender = false;
            this.Sender = sender;
            this.Addressee = addressee;
            this.Date = date;
            this.Subject = subject;
            this.Message = message;
        }
Esempio n. 23
0
        protected void addCredits(object sender, EventArgs e)
        {
            Button b = sender as Button;
            int credits = Int32.Parse(b.CommandArgument.ToString());

            UserBE user = new UserBE();
            user.Nickname = Session["UserNickname"].ToString();
            user = user.getUserByNick();

            user.Credit += credits;
            user.update();
            Session["UserCredit"] = user.Credit;

            user = user.getUserByNick();
            labelCredits.Text = credits.ToString() + " Credits Added! Now you have " + user.Credit.ToString() + " credits!";
        }
Esempio n. 24
0
        protected void create_Project(object sender, EventArgs e)
        {
            bool correct = true;

            if (creditsTextboxProject.Text.Length == 0 ||
                Int32.Parse(creditsTextboxProject.Text) > Int32.Parse(Session["UserCredit"].ToString()))
            {
                creditsFeedback.Visible = true;
                correct = false;
            }
            else
                creditsFeedback.Text = "";

            if (correct)
            {
                //Project information.
                String tittle = tittleProjectTextbox.Text;
                String description = descriptionTextbox.Text;
                UserBE user1 = new UserBE("", 0, "", "", Session["UserNickname"].ToString(), "");
                UserBE creator = new UserBE(user1.getUserByNick());
                int code = -1;
                DateTime creation = DateTime.Now;
                DateTime expires = DateTime.MinValue;
                int credit = Int32.Parse(creditsTextboxProject.Text);
                DateTime version = DateTime.Now;
                String gitDir = "There";

                //Update the UserBE credits and also the Sessión value.
                String currentCredits = Session["UserCredit"].ToString();
                Session["UserCredit"] = Int32.Parse(currentCredits) - credit;
                creator.Credit = Int32.Parse(currentCredits) - credit;
                creator.update();

                //Project creation.
                ProjectBE crProject = new ProjectBE(tittle, description, creator, code,
                    creation, expires, credit, credit, version, gitDir);
                crProject.create();
                crProject.Code = crProject.getLastCode();

                //When you create a project, you are contributing to it.
                ContributionBE contribution = new ContributionBE(creator, crProject, credit, DateTime.Now);
                contribution.create();

                creationFeedback.Text = "Project created successfully!";
                creationFeedback.ForeColor = System.Drawing.Color.Green;
            }
        }
Esempio n. 25
0
        protected void grid_RowCommand(int code)
        {
            MessageBE message = MessageDAC.getMessage(code);

            UserBE user1 = new UserBE("", 0, "", "", Session["UserNickname"].ToString(), "");
            UserBE currentUser = new UserBE(user1.getUserByNick());
            message.removeMessage(currentUser);

            if (Request.QueryString["Box"] == "Out")
            {
                Response.Redirect("ProfileMessages.aspx?Box=Out");
            }
            else
            {
                Response.Redirect("ProfileMessages.aspx?Box=In");
            }
        }
Esempio n. 26
0
        public ProjectBE(string title, string description,
                            UserBE creator, string code,
                            DateTime creationDate, DateTime expirationDate,
                            float credit, DateTime lastVersion,
                            string gitDir)
        {
            this.code = generateCode();
            this.state = ProjectState.Active;

            this.title = title;
            this.description = description;
            this.creator = creator;
            this.credit = credit;
            this.creationDate = creationDate;
            this.expirationDate = expirationDate;
            this.lastVersion = lastVersion;
            this.gitDir = gitDir;
        }
Esempio n. 27
0
        protected void contribute(object sender, EventArgs e)
        {
            if (creditsBox.Text.Length > 2)
            {
                if (Int32.Parse(creditsBox.Text) <= Int32.Parse(Session["UserCredit"].ToString()))
                {
                    //Get the query string parameters.
                    string projectTitle = Session["ProjectTitle"].ToString();
                    int projectCode = Int32.Parse(Session["ProjectCode"].ToString());
                    int credits = Int32.Parse(creditsBox.Text);

                    //Create a project and look for the one we are being asked.
                    ProjectBE project = new ProjectBE();
                    project.Code = projectCode;
                    project = project.getByCode();

                    project.Credit = project.Credit + credits;
                    project.PartitionCredit = project.PartitionCredit + credits;

                    project.update();

                    //We need the user, so we update its credits.
                    UserBE usuario = new UserBE();
                    usuario.Email = Session["UserEmail"].ToString();
                    usuario = usuario.getUserByEmail();
                    usuario.Credit = usuario.Credit - credits;
                    usuario.update();
                    Session["UserCredit"] = usuario.Credit;

                    //And we must also create the contribution entry.
                    ContributionBE contr = new ContributionBE(usuario, project, Int32.Parse(creditsBox.Text), DateTime.Now);
                    contr.create();

                    FeedbackCredit.Text = "Done!";
                    projectProfileLabelCredits.Text = project.Credit.ToString();
                    FeedbackCredit.Visible = true;
                }
                else
                {
                    FeedbackCredit.Text = "Wrong quantity.";
                    FeedbackCredit.Visible = true;
                }
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Auxiliary Constructor.
        /// Creates a new project business entity filling the fields
        /// with the provided ones.
        /// </summary>
        /// <param name="title">The title of the project.</param>
        /// <param name="description">The description of the project.</param>
        /// <param name="creator">The user which created the project.</param>
        /// <param name="code">The code of the project.</param>
        /// <param name="creationDate">The creation date.</param>
        /// <param name="expirationDate">The deadline of the project.</param>
        /// <param name="credit">The amount of credits the project has.</param>
        /// <param name="partitionCredit">The amount of credits in the current partition.</param>
        /// <param name="lastVersion">The date of the last partition.</param>
        /// <param name="gitDir">The git directory of the project.</param>
        public ProjectBE(string title, string description,
            UserBE creator, int code,
            DateTime creationDate, DateTime expirationDate,
            int credit, int partitionCredit, DateTime lastVersion,
            string gitDir)
        {
            this.code = code;
            this.state = ProjectState.Active;

            this.title = title;
            this.description = description;
            this.creator = creator;
            this.credit = credit;
            this.partitionCredit = partitionCredit;
            this.creationDate = creationDate;
            this.expirationDate = expirationDate;
            this.lastVersion = lastVersion;
            this.gitDir = gitDir;
        }
Esempio n. 29
0
        //Method that returns an user of type UserBE
        public UserBE getUser(String email)
        {
            UserBE user = new UserBE();

            SqlConnection c = new SqlConnection(connection);
            c.Open();

            SqlCommand com = new SqlCommand("SELECT * FROM Users WHERE email='" + email + "'", c);

            SqlDataReader dr = com.ExecuteReader();

            while(dr.Read())
            {
                user.Name = dr["name"].ToString();
                user.LastName = dr["last_name"].ToString();
                user.Email = dr["email"].ToString();
                user.Nickname = dr["nickname"].ToString();
                user.Password = dr["password"].ToString();
                user.Credit = Int32.Parse(dr["credits"].ToString());
            }

            c.Close();
            return user;
        }
Esempio n. 30
0
        protected void logIn(object sender, EventArgs e)
        {
            string nick = Login1.UserName;
            string password = Login1.Password;
            bool exists = false;

            UserBE user = new UserBE();
            user.Nickname = nick;
            user.Password = password;
            exists = user.verifyUser();

            if (exists)
            {
                HttpCookie userCookie = new HttpCookie("UserNickname", user.Nickname);
                userCookie.Expires = DateTime.Now.AddMonths(2);
                Response.Cookies.Add(userCookie);

                Response.Redirect("Default.aspx");
            }
            else
            {
                Login1.FailureText = "The user or the password do not match";
            }
        }