Пример #1
0
 public static USERS getAndSetConfirmUser(string email, string code, out string mensaje)
 {
     goliazco_FWEntities entity = null;
     USERS updateUser = null;
     mensaje = "";
     try
     {
         using (entity = new goliazco_FWEntities())
         {
             updateUser = (from t in entity.USERS where t.email == email && t.codeConfirm == code select t).FirstOrDefault();
             if (updateUser != null)
             {
                 updateUser.codeConfirm = "";
                 updateUser.estado = "Confirmed";
                 entity.SaveChanges();
             }
             else
             {
                 mensaje = "User not found or link not longer available";
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return updateUser;
 }
Пример #2
0
 public static List<DAYS> getActiveDaysForReport()
 {
     List<DAYS> activeDays = null;
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             activeDays = (from t in entity.DAYS where t.state == "Active" select t).ToList();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return activeDays;
 }
Пример #3
0
 public static List<DAYS> getDays()
 {
     List<DAYS> daysAvailables = null;
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             daysAvailables = (from t in entity.DAYS select t).ToList();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return daysAvailables;
 }
Пример #4
0
 public static DAYS getDay(int day)
 {
     DAYS getDay = null;
     goliazco_FWEntities entity =  null;
     try
     {
         entity = new goliazco_FWEntities();
         //getDay = (from t in entity.DAYS where t.Day == day select t).FirstOrDefault();
         getDay = (from t in entity.DAYS where t.idDay == day select t).FirstOrDefault();
         getDay.DAYS_CONFIG = (from t in entity.DAYS_CONFIG where t.idDay == getDay.idDay select t).ToList();
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return getDay;
 }
Пример #5
0
 /// <summary>
 /// Allow to delete an attached exercise to a day
 /// </summary>
 /// <param name="idExercise">The specific Id of Exercise</param>
 /// <returns>true or false that it was deleted</returns>
 public static bool DeleteExercise(int idExercise)
 {
     bool resp = false;
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             DAYS_CONFIG exercise = (from t in entity.DAYS_CONFIG where t.idReportNum == idExercise select t).FirstOrDefault();
             entity.DAYS_CONFIG.Remove(exercise);
             entity.SaveChanges();
             resp = true;
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return resp;
 }
Пример #6
0
 public static bool ingresarError(string error)
 {
     bool resp = true;
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             LOG_ERROR logerror = new LOG_ERROR();
             logerror.fecha = DateTime.Now;
             logerror.error = error;
             entity.LOG_ERROR.Add(logerror);
             entity.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return resp;
 }
Пример #7
0
 public static bool DeleteUser(int idUser)
 {
     bool resp = false;
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             USERS userDeleted = (from t in entity.USERS where t.idUser == idUser select t).FirstOrDefault();
             //if (userDeleted.DAYS_REPORT != null && userDeleted.DAYS_REPORT.Count > 0)
             //{
             //    foreach (DAYS_REPORT diaReportado in userDeleted.DAYS_REPORT)
             //    {
             //        if (diaReportado != null)
             //        {
             //            if (diaReportado.REPORT_DAY != null && diaReportado.REPORT_DAY.Count > 0)
             //            {
             //                foreach (REPORT_DAY rep in diaReportado.REPORT_DAY)
             //                {
             //                    entity.REPORT_DAY.Remove(rep);
             //                }
             //            }
             //            entity.DAYS_REPORT.Remove(diaReportado);
             //        }
             //    }
             //}
             if (userDeleted != null)
             {
                 entity.USERS.Remove(userDeleted);
                 entity.SaveChanges();
                 resp = true;
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return resp;
 }
Пример #8
0
 public static bool SaveChangesUser(int idUser, string name, string email, string country, string gender, string birthDate, string poseidonPB, string hadesPB, string venusPB)
 {
     bool resp = false;
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             USERS currentUser = (from t in entity.USERS where t.idUser == idUser select t).FirstOrDefault();
             if (currentUser != null)
             {
                 currentUser.name = name;
                 currentUser.email = email;
                 currentUser.nationality = country;
                 currentUser.gender = gender;
                 if (!string.IsNullOrEmpty(poseidonPB))
                     currentUser.poseidon_pb = poseidonPB;
                 if (!string.IsNullOrEmpty(hadesPB))
                     currentUser.hades_pb = hadesPB;
                 if (!string.IsNullOrEmpty(venusPB))
                     currentUser.venus_pb = venusPB;
                 string[] formats = { "dd/MM/yyyy" };
                 currentUser.birthDate = DateTime.ParseExact(birthDate, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                 entity.SaveChanges();
                 resp = true;
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return resp;
 }
Пример #9
0
 public static USERS registerUser(USERS user)
 {
     goliazco_FWEntities entity = null;
     try
     {
         using (entity = new goliazco_FWEntities())
         {
             entity.USERS.Add(user);
             entity.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return user;
 }
Пример #10
0
 public static USERS loginUser(string email, string pass)
 {
     USERS getLogedUser = null;
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             getLogedUser = (from t in entity.USERS where t.email == email && t.pass == pass select t).FirstOrDefault();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return getLogedUser;
 }
Пример #11
0
 public static List<USERS> getUsers()
 {
     List<USERS> usersList = null;
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             usersList = (from t in entity.USERS orderby t.name select t).ToList();
             foreach (USERS user in usersList)
             {
                 user.age = GetAge(user.birthDate);
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return usersList;
 }
Пример #12
0
 public static DAYS_REPORT getReportedDayByUser(int idUser, int day)
 {
     DAYS_REPORT reportedDay = null;
     goliazco_FWEntities entity = null;
     try
     {
         entity = new goliazco_FWEntities();
         entity.Configuration.LazyLoadingEnabled = true;
         reportedDay = (from t in entity.DAYS_REPORT where t.idUser == idUser && t.day == day select t).FirstOrDefault();
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return reportedDay;
 }
Пример #13
0
 public static bool saveNewDay(int day, string date, string state)
 {
     bool resp = false;
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             DAYS newDay = new DAYS();
             string[] formats = { "dd/MM/yyyy" };
             newDay.Day = day;
             newDay.completeDay = DateTime.ParseExact(date, formats, new CultureInfo("en-US"), DateTimeStyles.None);
             newDay.state = state;
             entity.DAYS.Add(newDay);
             entity.SaveChanges();
             resp = true;
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return resp;
 }
Пример #14
0
        public static bool SaveInform(int idUser, int day, int idRegister, int[] idReportedDays, string[] names, string[] dataTypes, string[] inform)
        {
            bool resp = false;
            try
            {
                goliazco_FWEntities entity = new goliazco_FWEntities();
                if (idRegister > 0)
                {
                    DAYS_REPORT reportedDay = (from t in entity.DAYS_REPORT where t.idRegister == idRegister && t.idUser == idUser select t).FirstOrDefault();
                    reportedDay.date = DateTime.Now;
                    if (reportedDay != null)
                    {
                        int i;
                        for (i = 0; i < idReportedDays.Length; i++)
                        {
                            REPORT_DAY reporteDeDia = (from t in reportedDay.REPORT_DAY where t.idReportDay == idReportedDays[i] select t).FirstOrDefault();
                            reporteDeDia.Name = names[i];
                            reporteDeDia.DataInform = dataTypes[i];
                            reporteDeDia.Inform = inform[i];
                        }
                        if (names.Length > idReportedDays.Length)
                        {

                            for (int j = i; j < names.Length; j++)
                            {
                                REPORT_DAY newReport = new REPORT_DAY();
                                newReport.Name = names[j];
                                newReport.DataInform = dataTypes[j];
                                newReport.Inform = inform[j];
                                reportedDay.REPORT_DAY.Add(newReport);
                            }
                        }
                    }
                    entity.SaveChanges();
                    resp = true;
                }
                else
                {
                    entity.Configuration.LazyLoadingEnabled = true;
                    entity.Configuration.ValidateOnSaveEnabled = true;

                    DAYS_REPORT newReportedDay = new DAYS_REPORT();
                    newReportedDay.USERS = (from t in entity.USERS where t.idUser == idUser select t).FirstOrDefault();
                    newReportedDay.day = day;
                    newReportedDay.date = DateTime.Now;
                    for (int i = 0; i < names.Length; i++)
                    {
                        //THis is a new report any day. only report 1 excercise
                        REPORT_DAY reportForDay = new REPORT_DAY();
                        reportForDay.Inform = inform[i];
                        reportForDay.Name = names[i];
                        reportForDay.DataInform = dataTypes[i];
                        newReportedDay.REPORT_DAY.Add(reportForDay);
                    }
                    entity.DAYS_REPORT.Add(newReportedDay);
                    entity.SaveChanges();
                    resp = true;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return resp;
        }
Пример #15
0
        public static bool SaveConfigForDay(int day, int idDay, string date, string state, int[] idDiasConfigurados, string[] names, string[] dataTypes, string[] descriptions)
        {
            bool resp = false;
            try
            {
                goliazco_FWEntities entity = new goliazco_FWEntities();
                if (idDay > 0)
                {
                    DAYS dayConfig = (from t in entity.DAYS where t.idDay == idDay select t).FirstOrDefault();
                    if (dayConfig != null)
                    {
                        string[] formats = { "dd/MM/yyyy" };
                        dayConfig.completeDay = DateTime.ParseExact(date, formats, new CultureInfo("en-US"), DateTimeStyles.None);
                        dayConfig.state = state;
                        int i = 0;
                        if (dayConfig.DAYS_CONFIG != null && dayConfig.DAYS_CONFIG.Count > 0)
                        {
                            for (i = 0; i < idDiasConfigurados.Length; i++)
                            {
                                DAYS_CONFIG diaYaConfigurado = (from t in dayConfig.DAYS_CONFIG where t.idReportNum == idDiasConfigurados[i] select t).FirstOrDefault();
                                diaYaConfigurado.name = names[i];
                                diaYaConfigurado.dataType = dataTypes[i];
                                diaYaConfigurado.description = descriptions[i];
                            }
                        }
                        if (names.Length > idDiasConfigurados.Length)
                        {

                            for (int j = i; j < names.Length; j++)
                            {
                                DAYS_CONFIG newConfigForDay = new DAYS_CONFIG();
                                newConfigForDay.name = names[j];
                                newConfigForDay.dataType = dataTypes[j];
                                newConfigForDay.description = descriptions[j];
                                dayConfig.DAYS_CONFIG.Add(newConfigForDay);
                            }
                        }
                    }
                    entity.SaveChanges();
                    resp = true;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return resp;
        }
Пример #16
0
 public static USERS updateUser(USERS user, string codeNew)
 {
     goliazco_FWEntities entity = null;
     USERS updateUser = null;
     try
     {
         using (entity = new goliazco_FWEntities())
         {
             updateUser = (from t in entity.USERS where t.idUser == user.idUser select t).FirstOrDefault();
             updateUser.codeConfirm = codeNew;
             entity.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return updateUser;
 }
Пример #17
0
 public static USERS validateUser(USERS user)
 {
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             user = (from t in entity.USERS where t.idUser == user.idUser select t).FirstOrDefault();
             user.estado = "Confirmed";
             entity.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return user;
 }
Пример #18
0
 public static List<REPORT_DAY> getDiasReportados(int iddia)
 {
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             return (from p in entity.REPORT_DAY where p.idRegister == iddia select p).ToList();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return null;
 }
Пример #19
0
 public static DAYS_REPORT getDiaReportado(int idUser, int day)
 {
     DAYS_REPORT dia = null;
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             dia = (from t in entity.DAYS_REPORT where t.idUser == idUser && t.day == day select t).FirstOrDefault();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return dia;
 }
Пример #20
0
 public static USERS getUser(int idUser)
 {
     USERS user = null;
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             user = (from t in entity.USERS where t.idUser == idUser select t).FirstOrDefault();
         }
     }
     catch (Exception ex)
     {
     }
     return user;
 }