Exemplo n.º 1
0
 public long getLikes(Publication p)
 {
     return(_ds.getLikeCount(p));
 }
Exemplo n.º 2
0
 public bool createPublication(Publication pub)
 {
     return(_ds.createPublication(pub));
 }
Exemplo n.º 3
0
 public bool giveLike(User u, Publication p)
 {
     return(_ds.giveLike(u, p));
 }
Exemplo n.º 4
0
 public void removeLike(User u, Publication p)
 {
     _ds.deleteLike(u, p);
 }
Exemplo n.º 5
0
        public bool createPublication(Publication publication)
        {
            var result = false;

            try
            {
                if (_client.Open())
                {
                    var command = new SqlCommand
                    {
                        Connection  = _client.connection,
                        CommandText = "createPublication",
                        CommandType = CommandType.StoredProcedure
                    };

                    var par1 = new SqlParameter("@ID", SqlDbType.NVarChar)
                    {
                        Direction = ParameterDirection.Input,
                        Value     = publication.id
                    };

                    var par2 = new SqlParameter("@profile", SqlDbType.NVarChar)
                    {
                        Direction = ParameterDirection.Input,
                        Value     = publication.username
                    };
                    var par4 = new SqlParameter("@date", SqlDbType.DateTime)
                    {
                        Direction = ParameterDirection.Input,

                        Value = publication.date.ToString("yyyy-MM-dd HH:mm:ss.fff")
                    };

                    var par5 = new SqlParameter("@imgPath", SqlDbType.NVarChar)
                    {
                        Direction = ParameterDirection.Input,

                        Value = publication.imgPath
                    };
                    var par6 = new SqlParameter("@description", SqlDbType.NVarChar)
                    {
                        Direction = ParameterDirection.Input,

                        Value = publication.description
                    };
                    var par3 = new SqlParameter("@haserror", SqlDbType.Bit)
                    {
                        Direction = ParameterDirection.Output
                    };
                    command.Parameters.Add(par1);
                    command.Parameters.Add(par2);
                    command.Parameters.Add(par4);
                    command.Parameters.Add(par5);
                    command.Parameters.Add(par6);
                    command.Parameters.Add(par3);
                    command.ExecuteNonQuery();

                    result = !Convert.ToBoolean(command.Parameters["@haserror"].Value.ToString());
                }
            }
            catch (Exception)
            {
                result = false;
            }
            finally
            {
                _client.Close();
            }

            return(result);
        }