public void Momento_PeristRetrieveAddComment_TheCommentSeedIdIsMaintained()
        {
            IDocumentStore    documentStore = GetRavenDb();
            IDocumentDatabase database      = new RavenDb(documentStore);

            Momento momento     = new Momento();
            string  commentName = Guid.NewGuid().ToString();

            momento.AddComment(new Comment {
                Author = commentName
            });

            database.Add(momento);
            database.Save();

            Momento momento2 = database.SingleOrDefault <Momento>(m => m.Id == momento.Id);

            string  commentName2 = Guid.NewGuid().ToString();
            Comment comment1     = new Comment {
                Author = commentName2
            };

            momento2.AddComment(comment1);

            const int expectedAutoGeneratedId = 2;

            Assert.AreEqual(comment1.Id, expectedAutoGeneratedId);
        }
Example #2
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Sumário do Pedido:");
            sb.Append("Momento do Pedido: ");
            sb.AppendLine(Momento.ToString("dd/MM/yyyy HH:mm:ss"));
            sb.Append("Status do Pedido: ");
            sb.AppendLine(Status.ToString());
            sb.Append("Cliente: ");
            sb.Append(Cliente.Nome);
            sb.Append(" (");
            sb.Append(Cliente.DataNascimento.ToString("dd/MM/yyyy"));
            sb.Append(") - ");
            sb.AppendLine(Cliente.Email);
            sb.AppendLine("Itens do Pedido:");
            foreach (ItemPedido item in Items)
            {
                sb.Append(item.Produto.Nome);
                sb.Append(", $");
                sb.Append(item.Preco);
                sb.Append(", Quantidade: ");
                sb.Append(item.Quantidade);
                sb.Append(", Subtotal: $");
                sb.AppendLine(item.SubTotal().ToString());
            }
            sb.Append("Preço Total: $");
            sb.AppendLine(Total().ToString());

            return(sb.ToString());
        }
Example #3
0
        public ActionResult ById(int id)
        {
            Momento detail = _repository.GetById(id);

            detail = detail ?? new Momento();

            Func <string, string> convertNullToEmptyString = (s => s ?? string.Empty);

            return(Json(new
            {
                Added = detail.CreateDate.HasValue ? detail.CreateDate.Value.ToString("MMMM dd, yyyy") : string.Empty,
                AddedUrl = detail.CreateDate.HasValue ? string.Format("{0}/{1}/{2}", detail.CreateDate.Value.Year, detail.CreateDate.Value.Month, detail.CreateDate.Value.Day) : string.Empty,
                detail.UploadedBy,
                Albums = detail.Albums.Select(a => new { id = a.Id, name = a.Name }).ToArray(),
                detail.Day,
                DisplayName = convertNullToEmptyString(detail.User.FullName),
                Location = convertNullToEmptyString(detail.Location),
                Month = convertNullToEmptyString(Convert.ToString(detail.Month)),
                People = detail.People.Select(p => new { p.Username, p.Name }),
                Story = convertNullToEmptyString(detail.Story),
                Username = convertNullToEmptyString(detail.User.Username),
                Title = convertNullToEmptyString(detail.Title),
                Year = convertNullToEmptyString(Convert.ToString(detail.Year))
            }));
        }
Example #4
0
        /// <summary>
        /// Saves the exif information.
        /// </summary>
        /// <param name="bytes">The bytes.</param>
        /// <param name="momento">The momento.</param>
        /// <param name="session">The session.</param>
        /// <returns>System.Nullable{DateTime}.</returns>
        private static DateTime?SaveExifInformation(byte[] bytes, Momento momento, ISession session)
        {
            var      imageMetadata = new ExifData(session);
            DateTime?photoDateTime = imageMetadata.ExtractExifSave(new MemoryStream(bytes), momento);

            return(photoDateTime);
        }
        public void Momento_MarkCommentAsSpam_CorrectCommentIsMarkedAsSpamAndPersistedToDataStore()
        {
            IDocumentStore    documentStore = GetRavenDb();
            IDocumentDatabase database      = new RavenDb(documentStore);

            Momento momento     = new Momento();
            string  commentName = Guid.NewGuid().ToString();

            momento.AddComment(new Comment()
            {
                Author = commentName
            });

            database.Add(momento);
            database.Save();

            Momento momento2 = database.SingleOrDefault <Momento>(m => m.Id == momento.Id);
            Comment comment  = momento2.Comments.Where(c => c.Author == commentName).SingleOrDefault();

            momento.MarkCommentAsSpam(comment.Id);

            database.Add(momento);
            database.Save();

            Momento momento3 = database.SingleOrDefault <Momento>(m => m.Id == momento.Id);
            Comment comment2 = momento3.Comments.Where(c => c.Author == commentName).SingleOrDefault();

            Assert.AreEqual(CommentStatus.Spam, comment2.Status);
        }
Example #6
0
        /// <summary>
        /// Executes the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        public void Execute(MarkCommentAsSpamCommand command)
        {
            Momento momento = _database.SingleOrDefault <Momento>((m) => m.Id == command.MomentoId);

            momento.MarkCommentAsSpam(command.CommentId);

            _database.Add(momento);
        }
Example #7
0
        public Momento Carregar(int Id)
        {
            using (SqlConnection conn = new SqlConnection(@"Initial Catalog=HNI;Data Source = localhost; Integrated Security=SSPI"))
            {
                string strSQL = @"SELECT * FROM Momento where Personagem= '" + Id + "'";

                using (SqlCommand cmd = new SqlCommand(strSQL))
                {
                    conn.Open();
                    cmd.Connection  = conn;
                    cmd.CommandText = strSQL;
                    var dataReader = cmd.ExecuteReader();
                    var dt         = new DataTable();
                    dt.Load(dataReader);
                    conn.Close();

                    foreach (DataRow row in dt.Rows)
                    {
                        var A = new Momento()
                        {
                            Questao = new Questao()
                            {
                                Id = Convert.ToInt32(row["Questao"]),
                            },
                            Lugar = new Lugar()
                            {
                                Id = Convert.ToInt32(row["Lugar"]),
                            },
                            Cena = new Cena()
                            {
                                Id = Convert.ToInt32(row["Cena"]),
                            }
                        };
                        return(A);
                    }
                }
            }
            Momento E = new Momento();

            E.Cena = new Cena()
            {
                Id = 0,
            };
            E.Questao = new Questao()
            {
                Id = 0,
            };
            E.Lugar = new Lugar()
            {
                Id = 0,
            };

            return(E);
        }
Example #8
0
        /// <summary>
        /// Saves the automatic album.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="session">The session.</param>
        /// <param name="momento">The momento.</param>
        private static void SaveToAlbum(MediaMessage message, ISession session, Momento momento)
        {
            if (message.AlbumId.HasValue)
            {
                var album        = session.Get <Album>(message.AlbumId);
                var albumMomento = new AlbumMomento {
                    Album = album, Momento = momento
                };

                session.Save(albumMomento);
            }
        }
Example #9
0
 public Momento addMomento(decimal solution)
 {
     if (m_currentMomento == null)
     {
         m_currentMomento = new CSCI312_Assignment_5_Schmidt.Calculator.Momento(solution);
     }
     else
     {
         Momento newMomento = new Momento(m_currentMomento, solution);
         m_currentMomento = newMomento;
     }
     return(m_currentMomento);
 }
Example #10
0
 public Momento undoMomento()
 {
     if (m_currentMomento == null || m_currentMomento.getLastMomento() == null)
     {
         return(null);
     }
     else
     {
         Momento undoMomento = m_currentMomento.getLastMomento();
         m_currentMomento = undoMomento;
         return(m_currentMomento);
     }
 }
Example #11
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Data/Hora Pedido: " + Momento.ToString("dd/MM/yyyy HH:mm:ss"));
            sb.AppendLine("Cliente: " + Cliente);
            sb.AppendLine("Items do Pedido:");
            foreach (PedidoItem item in Items)
            {
                sb.AppendLine(item.ToString());
            }
            sb.AppendLine("Preco Total: $ " + Total().ToString("F2", CultureInfo.InvariantCulture));
            return(sb.ToString());
        }
Example #12
0
        /// <summary>
        /// Populates the momento object.
        /// </summary>
        /// <param name="mediaMessage">The media message.</param>
        /// <returns>Momento.</returns>
        private static Momento PopulateMomentoObject(MediaMessage mediaMessage)
        {
            var momento = new Momento
            {
                InternalId = mediaMessage.Id,
                User       = new User {
                    Username = mediaMessage.Username
                },
                UploadedBy = mediaMessage.Username,
                Visibility = "Public"
            };

            return(momento);
        }
Example #13
0
        public override string ToString()
        {
            StringBuilder texto = new StringBuilder();

            texto.Append("Momento do serviço: ");
            texto.AppendLine(Momento.ToString("dd/MM/yyyy HH:mm:ss"));
            texto.Append("Status do serviço: " + Status);
            texto.AppendLine("Cliente: " + Cliente);
            texto.AppendLine("Itens por ordem de compra:");
            foreach (ListaProduto l in Items)
            {
                texto.AppendLine(l.ToString());
            }
            return(texto.ToString());
        }
Example #14
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Momento do pedido: " + Momento.ToString("dd/MM/yyyy HH:mm:ss"));
            sb.AppendLine("Status do pedido: " + Status);
            sb.AppendLine("Cliente: " + Cliente);
            sb.AppendLine("Itens do pedido:");
            foreach (ItemPedido item in Itens)
            {
                sb.AppendLine(item.ToString());
            }
            sb.AppendLine("Preco total: R$" + Total().ToString("F2", CultureInfo.InvariantCulture));
            return(sb.ToString());
        }
Example #15
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Momento da ordem: " + Momento.ToString("dd/MM/yyyy HH:mm:ss"));
            sb.AppendLine("Ordem dos status: " + Status);
            sb.AppendLine("Cliente: " + Cliente);
            sb.AppendLine("Ordem dos items");
            foreach (OrdemItem item in Items)
            {
                sb.AppendLine(item.ToString());
            }
            sb.AppendLine("Total preço: $" + Total().ToString("F2", CultureInfo.InvariantCulture));
            return(sb.ToString());
        }
Example #16
0
        /// <summary>
        /// Retorna as informações da mesa impressas;
        /// </summary>
        /// <returns>String formatada as infos da mesa.</returns>
        public override string ToString()
        {
            string conteudo = "";

            conteudo += "Informação da mesa: " + Environment.NewLine;
            conteudo += "Rodada: " + NumRodada + "/" + NumMaximoRodadas + Environment.NewLine;
            conteudo += "Momento Jogo: " + Momento.ToString() + Environment.NewLine;
            conteudo += "Flop: " + PrintFlop() + Environment.NewLine;
            conteudo += "Turn: " + PrintTurn() + Environment.NewLine;
            conteudo += "River: " + PrintRiver() + Environment.NewLine;
            conteudo += "Cartas Banca: " + PrintCartasBanca() + Environment.NewLine;
            conteudo += "Jogador (" + Jogador.Stack + ") " + PrintCartasJogador() + Environment.NewLine;
            conteudo += "Valores investidos: " + "[" + ValorInvestidoAnt + " " + ValorInvestidoFlop + " " + ValorInvestidoTurn + " " + ValorInvestidoRiver + "]" + Environment.NewLine;

            return(conteudo);
        }
        public override string ToString()
        {
            StringBuilder x = new StringBuilder();

            x.AppendLine(Titulo);
            x.Append(Likes);
            x.Append(" Likes - ");
            x.AppendLine(Momento.ToString("dd/MM/yyyy HH:mm:ss "));
            x.AppendLine(Conteudo);
            x.AppendLine(" Comentarios: ");
            foreach (Comentarios c in Comentario)
            {
                x.AppendLine(c.Texto);
            }
            return(x.ToString());
        }
Example #18
0
        public override string ToString()
        {
            StringBuilder StringBD = new StringBuilder();

            StringBD.AppendLine(Titulo);
            StringBD.Append(Likes);
            StringBD.Append(" Likes - ");
            StringBD.AppendLine(Momento.ToString("dd/MM/yy HH:mm:ss"));
            StringBD.AppendLine(Conteudo);
            StringBD.AppendLine("Comentários: ");
            foreach (Comment C in Comentarios)
            {
                StringBD.AppendLine(C.Text);
            }
            return(StringBD.ToString());
        }
Example #19
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(Titulo);
            sb.Append(Likes);
            sb.Append(" Likes - ");
            sb.AppendLine(Momento.ToString("dd/MM/yyyy HH:mm:ss"));
            sb.AppendLine(Conteudo);
            sb.AppendLine("Comentários");
            foreach (Comentarios item in Comentarios)
            {
                sb.AppendLine(item.Texto);
            }
            return(sb.ToString());
        }
Example #20
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Data do pedido: " + Momento.ToString("dd/MM/yyyy HH:mm:ss"));
            sb.AppendLine("Status do pedido: " + Status);
            sb.AppendLine("Cliente: " + cliente);
            sb.AppendLine("Itens do pedido:");

            foreach (ItemPedido novo in ListaItens)
            {
                sb.AppendLine(novo.ToString());
            }

            sb.AppendLine("Valor Total: $" + Total().ToString("F2", CultureInfo.InvariantCulture));
            return(sb.ToString());
        }
Example #21
0
        public override string ToString()
        {
            StringBuilder text = new StringBuilder();

            text.AppendLine("Criação do Pedido: " + Momento.ToString("dd/MM/yyyy HH:mm:ss"));
            text.AppendLine("Status do Pedido: " + Status);
            text.AppendLine("Cliente: " + _cliente);
            text.AppendLine("Itens do Pedido");

            foreach (ItemPedido item in itensPedido)
            {
                text.AppendLine(item.ToString());
            }

            text.AppendLine("Preço Total $: " + TotalPreco().ToString("F2", CultureInfo.InvariantCulture));
            return(text.ToString());
        }
        /// <summary>
        ///     Saves the media.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="single">The single.</param>
        private void SaveMedia(CreateMomentoParameters command, Momento single)
        {
            command.Media.ForEach(m => m.MomentoId = single.Id);
            List <Schema.MomentoMedia> media =
                command.Media.ConvertAll(Mapper.DynamicMap <CreateMomentoMediaParameters, Schema.MomentoMedia>);

            using (ITransaction transaction = _session.BeginTransaction())
            {
                foreach (Schema.MomentoMedia momentoMedia in media)
                {
                    momentoMedia.Momento = single;
                    _session.Save(momentoMedia);
                }

                transaction.Commit();
            }
        }
Example #23
0
        /// <summary>
        /// Usando o StringBuilder responsavel por montar uma string de forma eficiente
        /// pega o resultado em forma de string
        /// </summary>
        /// <returns></returns>
        public override string ToString() {

            StringBuilder sb = new StringBuilder();
            //sb.Append - adiciona no inicio
            //sb.AppendLine - addiciona linha no final.
            sb.AppendLine(Titulo);
            sb.Append(Likes);
            sb.Append(" Likes - ");
            sb.AppendLine(Momento.ToString("dd/MM/yyyy HH:mm:ss"));
            sb.AppendLine(Content);
            sb.AppendLine("Comentários: ");
            // Para percorrer a lista, colocar como variavel o item passado como parametro 
            // na lista, nesse caso Comment;
            foreach (Comment item in Comentarios) {
                sb.AppendLine(item.Texto);
            }
            return sb.ToString();
        }
Example #24
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(Titulo);
            sb.Append(Curtida);
            sb.Append(" Curtida - ");
            sb.AppendLine(Momento.ToString("DIA/MES/ANO HORA:minuto:segundo "));
            sb.AppendLine(Conteudo);
            sb.AppendLine("Comentarios: ");

            foreach (Comentario c in Comentarios)
            {
                sb.AppendLine(c.Texto);
            }

            return(sb.ToString());
        }
Example #25
0
        public override string ToString()
        {
            StringBuilder SB = new StringBuilder();

            /*
             * SB.AppendLine("***  RESUMO DO POEDIDO  ***");
             * SB.Append("Geração do pedido: ");
             * SB.AppendLine(Momento.ToString("dd/MM/yy HH:mm:ss"));
             * SB.Append("Situação do pedido: ");
             * SB.AppendLine(Status.ToString());
             * SB.Append("Cliente: ");
             * SB.Append(Cli.Nome);
             * SB.Append(" (");
             * SB.Append(Cli.Aniversario.ToString("dd/MM/YY"));
             * SB.Append(") - ");
             * SB.AppendLine(Cli.Email);
             * SB.AppendLine("Itens do Pedido:");
             *///  programa do professor
            SB.AppendLine("***  RESUMO DO PEDIDO  ***");
            SB.AppendLine("Geração do pedido: " + Momento.ToString("dd/MM/yy HH:mm:ss"));
            SB.AppendLine("Situação do pedido: " + Status.ToString());
            SB.AppendLine("Cliente: " + Cli.ToString());
            SB.AppendLine("Itens do Pedido:");

            foreach (OrderItem Item in Itens)
            {
                /*
                 * SB.Append(Item.P1.Nome);
                 * SB.Append(", ");
                 * SB.Append(Item.P1.Preco.ToString("F2"));
                 * SB.Append(", Quantidade: ");
                 * SB.Append(Item.Qtde.ToString());
                 * SB.Append(", Subtotal: ");
                 * SB.AppendLine(Item.SubTotal(Item.P1).ToString("F2"));
                 *///  programa do professor
                SB.AppendLine(Item.P1.ToString());
            }

            //   SB.Append("Valor total do Pedido: ");
            //   SB.AppendLine(Total().ToString("F2"));
            SB.AppendLine("Valor total do Pedido: " + Total().ToString("F2"));
            return(SB.ToString());
        }
Example #26
0
        /// <summary>
        /// Extracts the exif save.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="momento">The momento.</param>
        /// <returns>DateTime.</returns>
        public DateTime?ExtractExifSave(Stream stream, Momento momento)
        {
            DateTime?date = null;

            using (stream)
            {
                System.Drawing.Image image = System.Drawing.Image.FromStream(stream);
                PropertyItem[]       items = image.PropertyItems;

                if (items.Length > 0)
                {
                    var exifs = new List <Exif>();

                    foreach (PropertyItem propertyItem in items)
                    {
                        //The below codes output funky strings that won't go into the database.
                        string[] ignore = { "501b", "5091", "5090", "927c" };
                        string   id     = propertyItem.Id.ToString("x");
                        string   value  = Encoding.UTF8.GetString(propertyItem.Value);

                        if (!ignore.Contains(id))
                        {
                            var exif = new Exif
                            {
                                Momento = momento,
                                Key     = propertyItem.Id.ToString("x"),
                                Type    = propertyItem.Type,
                                Value   = string.IsNullOrWhiteSpace(value) ? string.Empty : value
                            };

                            exifs.Add(exif);
                        }

                        date = GetDate(id, value, date);
                    }

                    SaveExifs(exifs);
                }
            }

            return(date);
        }
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(Titulo);
            sb.Append(Curtidas);
            sb.Append(" Curtidas - ");
            sb.AppendLine(Momento.ToString("dd/MM/yyyy HH:mm:ss"));
            sb.AppendLine(Conteudo);
            sb.AppendLine("Comentários:");
            //precisaremos percorrer todos os comentários vinculados na postagem
            //para isso vamos usar o foreach, para cada coment dentro de Comentarios, imprimir
            //coment.texto
            foreach (Comentarios coment in Comentarios)
            {
                sb.AppendLine(coment.Texto);
            }
            //finalizando para retornar o valor do sb convertido em ToString();
            return(sb.ToString());
        }
        /// <summary>
        ///     Saves the momento.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <returns>Momento.</returns>
        private Momento SaveMomento(CreateMomentoParameters command)
        {
            Momento momento = _mapper.Map <CreateMomentoParameters, Momento>(command);

            momento.UploadedBy = command.Username;
            momento.InternalId = Guid.NewGuid();
            momento.Visibility = MomentoVisibility.Public;

            using (ITransaction trans = _session.BeginTransaction())
            {
                _session.Save(momento);
                _session.Save(new MomentoUser {
                    Momento = momento, Username = command.Username
                });

                trans.Commit();
            }

            return(momento);
        }
Example #29
0
        /// <summary>
        /// Executes the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        public void Execute(CreateCommentCommand command)
        {
            Momento momento = _database.SingleOrDefault <Momento>(c => c.Id == command.MomentoId);
            Comment comment = new Comment();

            comment.Author      = comment.Author;
            comment.AuthorEmail = command.AuthorEmail;
            comment.AuthorUrl   = command.AuthorUrl;
            comment.Body        = comment.Body;
            comment.UserAgent   = command.UserAgent;
            comment.UserIp      = command.UserIp;

            momento.AddComment(comment);

            _database.Add(momento);
            _database.Save();

            CommentMessage commentMessage = ConvertToCommentMessage(comment);

            _bus.Send(commentMessage);
        }
        /// <summary>
        /// Converts the automatic tile.
        /// </summary>
        /// <param name="c">The asynchronous.</param>
        /// <param name="settings">The settings.</param>
        /// <returns>Tile.</returns>
        public static Tile ConvertToTile(this Momento c, ISettings settings)
        {
            if (c.Media != null && c.Media.Any())
            {
                var url = string.Format("{0}/{1}", settings.CloudUrl,
                                        c.Media.Single(i => i.MediaType == MomentoMediaType.MediumImage).Url);

                var tile = new Tile
                {
                    Id         = c.Id,
                    ImageUrl   = url,
                    Story      = c.Story,
                    Title      = c.Title,
                    Username   = c.User.Username,
                    FullName   = c.User.FullName,
                    CreateDate = c.CreateDate
                };

                return(tile);
            }

            return(null);
        }
 public void EndEdit()
 {
     if (null == Snapshot)
     {
         throw new InvalidOperationException("EndEdit cannot successfully complete; BeginEdit was not invoked.");
     }
     Snapshot = null;
 }
 public void CancelEdit()
 {
     if (null == Snapshot)
     {
         throw new InvalidOperationException("CancelEdit cannot successfully complete; BeginEdit was not invoked.");
     }
     Snapshot.RestoreState(this);
     Snapshot = null;
 }
Example #33
0
		public void RestoreFromMomento(Momento momento) {
			this._state = momento.State;
			Console.WriteLine("Originator: resotring from momento {0}", this._state);
		}
 public void BeginEdit()
 {
     if (null == Snapshot)
     {
         Snapshot = new Momento<Blog>(this);
     }
 }