Ejemplo n.º 1
0
        //Metodo que agrega una App a la base de datos
        public static bool AddApp(string _Dev, string _Name, string _Description, string _Category, Byte[] _Photo)
        {
            using (var dbContext = new LAUNCHEntities())
            {
                var Existent = (from c in dbContext.APPs
                                where c.Name == _Name
                                select c).Any();
                if (Existent == true)
                {
                    return false;
                    //throw new InvalidOperationException("Ya existe un App con ese nombre. Escoge otro");
                }
                else
                {
                    int IdDeveloper = (from c in dbContext.DEVELOPERs
                                       where c.Email == _Dev
                                       select c.ID_Developer).First();

                    var app = new APP
                    {
                        ID_Developer = IdDeveloper,
                        Name = _Name,
                        PublishedDate = DateTime.Now,
                        Description = _Description,
                        Category = _Category,
                        Photo = _Photo,
                        MembershipQueue = false
                    };
                    dbContext.APPs.Add(app);
                    var changesSaved = dbContext.SaveChanges();
                    return changesSaved >= 1;
                }
            }
        }
Ejemplo n.º 2
0
 //Metodo que agrega comments a una aplicacion
 public static bool AddComment(CUSTOMER customer, APP app, string _content)
 {
     using (var dbContext = new LAUNCHEntities())
     {
         var comment = new COMMENT
         {
             ID_Customer = customer.ID_Customer,
             ID_App = app.ID_App,
             Date = DateTime.Now,
             Content = _content
         };
         dbContext.COMMENTs.Add(comment);
         var changesSaved = dbContext.SaveChanges();
         return changesSaved >= 1;
     }
 }
Ejemplo n.º 3
0
        //Lee todos los comments disponibles de una aplicacion
        public static List<COMMENT> getAllCommentsFromApp(APP app)
        {
            using (var dbContext = new LAUNCHEntities())
            {
                List<COMMENT> theComments = new List<COMMENT>();
                var getComments = from c in dbContext.COMMENTs
                                  where c.ID_App == app.ID_App
                                  select c;

                foreach (var c in getComments)
                {
                    theComments.Add(c);
                }
                return theComments;

            }
        }