Esempio 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;
                }
            }
        }
Esempio n. 2
0
        public static bool AddApp_Purchased(int  IdApp, string Correo)
        {
            using (var dbContext = new LAUNCHEntities())
            {
                var IdCustomer = (from c in dbContext.CUSTOMERs
                                  where c.Email == Correo
                                  select c.ID_Customer).Single();

                var app_purchased = new APP_PURCHASED
                {
                    ID_App = IdApp,
                    ID_Customer = IdCustomer
                };
                dbContext.APP_PURCHASED.Add(app_purchased);
                var changesSaved = dbContext.SaveChanges();
                return changesSaved >= 1;
            }
        }
Esempio n. 3
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;
     }
 }
Esempio n. 4
0
 public static bool updateDeveloper(string _firstName, string _lastName, string _email, string _password)
 {
     using (var dbContext = new LAUNCHEntities())
     {
         var buscarCustomer = from c in dbContext.DEVELOPERs
                              where c.Email == _email
                              select c;
         foreach (var c in buscarCustomer)
         {
             c.FirstName = _firstName;
             c.LastName = _lastName;
             c.Email = _email;
             c.Password = _password;
         }
         var changesSaved = dbContext.SaveChanges();
         return changesSaved >= 1;
     }
 }
Esempio n. 5
0
 public static bool AddMembership()
 {
     using (var dbContext = new LAUNCHEntities())
     {
         var membership = new MEMBERSHIP
         {
             LastPayment = DateTime.Now,
             Active = true
         };
         dbContext.MEMBERSHIPs.Add(membership);
         var changesSaved = dbContext.SaveChanges();
         return changesSaved >= 1;
     }
 }
Esempio n. 6
0
 //Metodo que agrega un Developer a la base de datos
 public static bool AddDeveloper(string _FirstName, string _LastName, string _Email, string _Password)
 {
     using (var dbContext = new LAUNCHEntities())
     {
         var Existent = (from c in dbContext.DEVELOPERs
                         where c.Email == _Email
                         select c).Any();
         //tira una excepcion si ya existe, y si no, agrega al developer a la base y lo guarda
         if (Existent == true)
         {
             throw new InvalidOperationException("Ya existe un developer con ese correo. Escoge otro");
         }
         else
         {
             try
             {
                 var developer = new DEVELOPER
                 {
                     FirstName = _FirstName,
                     LastName = _LastName,
                     Email = _Email,
                     Password = _Password
                 };
                 dbContext.DEVELOPERs.Add(developer);
                 var changesSaved = dbContext.SaveChanges();
                 return changesSaved >= 1;
             }
             catch (Exception ex)
             {
                 string error = ex.Message;
                 return false;
             }
         }
     }
 }
Esempio n. 7
0
        //Metodo que agrega un Customer a la base de datos
        public static bool AddCustomer(string _FirstName, string _LastName, string _Email, string _Password)
        {
            try
            {
                using (var dbContext = new LAUNCHEntities())
                {
                    dbContext.Database.Connection.Open();
                    //verifica si ya existe un customer en la base de datos con ese email
                    var Existent = (from c in dbContext.CUSTOMERs
                                    where c.Email == _Email
                                    select c).Any();
                    //tira una excepcion si ya existe, y si no, agrega al customer a la base y lo guarda
                    if (Existent == true)
                    {
                        throw new InvalidOperationException("Ya existe un usuario con ese correo. Escoge otro");
                    }

                    var customer = new CUSTOMER
                    {
                        FirstName = _FirstName,
                        LastName = _LastName,
                        Email = _Email,
                        Password = _Password
                    };
                    dbContext.CUSTOMERs.Add(customer);
                    var changesSaved = dbContext.SaveChanges();
                    return changesSaved >= 1;

                }
            }
            catch (Exception ex)
            {
                string error = ex.Message;
                return false;
            }
        }