public bool AddCommento(string testo, string email, string idmessaggio, string idRefCom = null)
        {
            //string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            Commento com = new Commento {
                Email       = email, Data = DateTime.Now,
                IDComRef    = idRefCom, TestoCommento = testo,
                IDMessaggio = idmessaggio, IDCommento = Guid.NewGuid().ToString()
            };

            _DbContext.Add(com);
            try
            {
                _DbContext.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }

            return(true);
        }
示例#2
0
 public void SetUp()
 {
     Factory.InitializeBugTracking(null, "password");
     Db    = Factory.LoadBugTracking(null, "password");
     User1 = new Utente()
     {
         Name      = "Stefano",
         Surname   = "Castello",
         Dob       = new DateTime(93, 12, 12),
         CodFisc   = "CSTSFN93D12D969U",
         Age       = 24,
         LogIn     = "******",
         Indirizzo = new Address()
         {
             Civico = 9, Interno = 2, Via = "viale Villa Chiesa"
         }
     };
     User2 = new Utente()
     {
         Name      = "Giorgio",
         Surname   = "Castello",
         Dob       = new DateTime(60, 07, 20),
         CodFisc   = "CSTGRG60L20D969A",
         Age       = 57,
         LogIn     = "******",
         Indirizzo = new Address()
         {
             Civico = 9, Interno = 2, Via = "viale Villa Chiesa"
         }
     };
     Prod1 = new Prodotto()
     {
         CommName = "Schermo",
         Id       = 10,
         Req      = new List <Prodotto>(),
         NotComp  = new List <Prodotto>()
     };
     Prod3 = new Prodotto()
     {
         CommName = "Android",
         Id       = 12,
         Req      = new List <Prodotto>(),
         NotComp  = new List <Prodotto>()
     };
     Prod2 = new Prodotto()
     {
         CommName = "iPhone",
         Id       = 11,
         Req      = new List <Prodotto> {
             Prod1
         },
         NotComp = new List <Prodotto> {
             Prod3
         }
     };
     Prod3.NotComp.Add(Prod2);
     Report1 = new Segnalazione()
     {
         Author       = User1,
         CreationDate = DateTime.Today,
         Descr        = "Sistema Orrendo!",
         SigProd      = Prod3,
         State        = "Aperta",
         Text         = "Nulla da aggingere !",
         Comments     = new List <Commento>()
     };
     Comment1 = new Commento()
     {
         Author       = User2,
         CreationDate = DateTime.Today,
         Text         = "Vero Meglio Apple!"
     };
 }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Inizializzo...");
            Factory.InitializeBugTracking(null, "password");

            Console.WriteLine("Accedo...");
            using (var db = Factory.LoadBugTracking(null, "password"))
            {
                var user1 = new Utente()
                {
                    Name      = "Stefano",
                    Surname   = "Castello",
                    Dob       = new DateTime(93, 12, 12),
                    CodFisc   = "CSTSFN93D12D969U",
                    Age       = 24,
                    LogIn     = "******",
                    Indirizzo = new Address()
                    {
                        Civico = 9, Interno = 2, Via = "viale Villa Chiesa"
                    }
                };
                var user2 = new Utente()
                {
                    Name      = "Giorgio",
                    Surname   = "Castello",
                    Dob       = new DateTime(60, 07, 20),
                    CodFisc   = "CSTGRG60L20D969A",
                    Age       = 57,
                    LogIn     = "******",
                    Indirizzo = new Address()
                    {
                        Civico = 9, Interno = 2, Via = "viale Villa Chiesa"
                    }
                };
                var prod1 = new Prodotto()
                {
                    CommName = "Schermo",
                    Id       = 10,
                    Req      = new List <Prodotto>(),
                    NotComp  = new List <Prodotto>()
                };
                var prod3 = new Prodotto()
                {
                    CommName = "Android",
                    Id       = 12,
                    Req      = new List <Prodotto>(),
                    NotComp  = new List <Prodotto>()
                };
                var prod2 = new Prodotto()
                {
                    CommName = "iPhone",
                    Id       = 11,
                    Req      = new List <Prodotto> {
                        prod1
                    },
                    NotComp = new List <Prodotto> {
                        prod3
                    }
                };
                prod3.NotComp.Add(prod2);
                var report1 = new Segnalazione()
                {
                    Author       = user1,
                    CreationDate = DateTime.Today,
                    Descr        = "Sistema Orrendo!",
                    SigProd      = prod3,
                    State        = "Aperta",
                    Text         = "Nulla da aggingere !",
                    Comments     = new List <Commento>()
                };
                var comment1 = new Commento()
                {
                    Author       = user2,
                    CreationDate = DateTime.Today,
                    Text         = "Vero Meglio Apple!"
                };
                db.Users.Add(user1);
                db.Users.Add(user2);
                db.Products.Add(prod1);
                db.Products.Add(prod2);
                db.Products.Add(prod3);
                db.Reports.Add(report1);
                db.Comments.Add(comment1);
                db.SaveChanges();



                var query = from u in db.Users
                            select u.CodFisc;
                foreach (var q in query)
                {
                    Console.WriteLine(q);
                }
                query = from u in db.Products
                        select u.CommName;
                foreach (var q in query)
                {
                    Console.WriteLine(q);
                }
            }



            Console.ReadLine();
        }
示例#4
0
        //Inserimento alla radice (lista di commenti della recensione)
        public void InserisciCommento(String testo, UtenteRegistrato autore)
        {
            Commento child = new Commento(testo, autore);

            _commenti.Add(child);

            OnRecensioneChanged();
        }