public ChurchReview Create(ChurchReview model)
        {
            var churchReview = new ChurchReview();

            using (var dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString))
            {
                if (dbconn.State == ConnectionState.Open)
                {
                    dbconn.Close();
                }
                dbconn.Open();

                using (var cmd = new SqlCommand("spInsertChurchReview", dbconn))
                {
                    try
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@userID", model.UserId);
                        cmd.Parameters.AddWithValue("@simbahanID", model.SimbahanId);
                        cmd.Parameters.AddWithValue("@name", model.Name);
                        cmd.Parameters.AddWithValue("@title", "");
                        cmd.Parameters.AddWithValue("@rate", model.StarCount);
                        cmd.Parameters.AddWithValue("@content", model.Comment);


                        var reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            churchReview = _churchReviewTransformer.Transform(reader);
                            if (churchReview.UserId != 0)
                            {
                                churchReview.User = _userTransformer.Transform(reader);
                            }
                            churchReview.Simbahan = _churchTransformer.Transform(reader);
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }

            return(churchReview);
        }
        public DailyReflectionReflection Create(DailyReflectionReflection model)
        {
            var dailyReflectionReflection = new DailyReflectionReflection();

            using (var dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString))
            {
                if (dbconn.State == ConnectionState.Open)
                {
                    dbconn.Close();
                }
                dbconn.Open();

                using (var cmd = new SqlCommand("spInsertUserDailyReflectionReflection", dbconn))
                {
                    try
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@userID", model.UserId);
                        cmd.Parameters.AddWithValue("@reflectionID", model.DailyReflectionId);
                        cmd.Parameters.AddWithValue("@title", model.Title);
                        cmd.Parameters.AddWithValue("@content", model.ReflectionContent);


                        var reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            dailyReflectionReflection = _reflectionReflectionTransformer.Transform(reader);
                            dailyReflectionReflection.DailyReflection = _dailyReflectionTransformer.Transform(reader);
                            dailyReflectionReflection.User            = _userTransformer.Transform(reader);
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }

            return(dailyReflectionReflection);
        }
        public Models.VisitaIglesia Create(Models.VisitaIglesia model)
        {
            var visitaIglesia = new Models.VisitaIglesia();

            using (var dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString))
            {
                if (dbconn.State == ConnectionState.Open)
                {
                    dbconn.Close();
                }
                dbconn.Open();

                using (var cmd = new SqlCommand("spInsertVisitaIglesia", dbconn))
                {
                    try
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@userID", model.UserId);
                        cmd.Parameters.AddWithValue("@simbahanID", model.SimbahanId);
                        cmd.Parameters.AddWithValue("@statusID", model.StatusId);


                        var reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            visitaIglesia        = _visitaIglesiaTransformer.Transform(reader);
                            visitaIglesia.Church = _churchTransformer.Transform(reader);
                            visitaIglesia.User   = _userTransformer.Transform(reader);
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }

            return(visitaIglesia);
        }
Exemplo n.º 4
0
        public Notification Create(Notification notification)
        {
            var createdNotification = new Notification();


            using (var dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString))
            {
                if (dbconn.State == ConnectionState.Open)
                {
                    dbconn.Close();
                }
                dbconn.Open();

                using (var cmd = new SqlCommand("spCreateNotification", dbconn))
                {
                    try
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@title", notification.Title);
                        cmd.Parameters.AddWithValue("@comment", notification.Description);
                        cmd.Parameters.AddWithValue("@userID", notification.UserId);
                        cmd.Parameters.AddWithValue("@action", notification.Action);

                        var reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            createdNotification      = _notificationTransformer.Transform(reader);
                            createdNotification.User = _userTransformer.Transform(reader);
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }

            return(createdNotification);
        }
        public OrganizationReview Create(OrganizationReview model)
        {
            var organizationReview = new OrganizationReview();

            using (var dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString))
            {
                if (dbconn.State == ConnectionState.Open)
                    dbconn.Close();
                dbconn.Open();

                using (var cmd = new SqlCommand("spInsertOrganizationReview", dbconn))
                {
                    try
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@userID", model.UserId);
                        cmd.Parameters.AddWithValue("@organizationID", model.OrganizationId);
                        cmd.Parameters.AddWithValue("@title", model.Title);
                        cmd.Parameters.AddWithValue("@rate", model.StarCount);
                        cmd.Parameters.AddWithValue("@content", model.Comment);


                        var reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            organizationReview = _organizationReviewTransformer.Transform(reader);
                            organizationReview.User = _userTransformer.Transform(reader);
                            organizationReview.Organization = _organizationTransformer.Transform(reader);
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }

            return organizationReview;
        }
Exemplo n.º 6
0
        public Notification Create(Notification notification)
        {
            var createdNotification = new Notification();

            using (var sp = new StoredProcedure("spCreateNotification"))
            {
                sp.SqlCommand.Parameters.AddWithValue("@title", notification.Title);
                sp.SqlCommand.Parameters.AddWithValue("@comment", notification.Description);
                sp.SqlCommand.Parameters.AddWithValue("@userID", notification.UserId);
                sp.SqlCommand.Parameters.AddWithValue("@action", notification.Action);

                var reader = sp.SqlCommand.ExecuteReader();

                while (reader.Read())
                {
                    createdNotification      = _notificationTransformer.Transform(reader);
                    createdNotification.User = _userTransformer.Transform(reader);
                }
            }

            return(createdNotification);
        }
Exemplo n.º 7
0
        public VisitaIglesia Create(VisitaIglesia model)
        {
            var visitaIglesia = new VisitaIglesia();

            using (var sp = new StoredProcedure("spInsertVisitaIglesia"))
            {
                sp.SqlCommand.Parameters.AddWithValue("@userID", model.UserId);
                sp.SqlCommand.Parameters.AddWithValue("@simbahanID", model.SimbahanId);
                sp.SqlCommand.Parameters.AddWithValue("@statusID", model.StatusId);

                var reader = sp.SqlCommand.ExecuteReader();

                while (reader.Read())
                {
                    visitaIglesia        = _visitaIglesiaTransformer.Transform(reader);
                    visitaIglesia.Church = _churchTransformer.Transform(reader);
                    visitaIglesia.User   = _userTransformer.Transform(reader);
                }
            }

            return(visitaIglesia);
        }
Exemplo n.º 8
0
        public CSUser GetUser(string email)
        {
            CSUser user = null;

            using (var db = new ManagementToolEntities())
            {
                var resp   = new UsersRepository(db);
                var dbUser = resp.GetFirstOrDefault(u => u.Email.Trim().ToLower() == email.Trim().ToLower());

                UserTransformer transformer = new UserTransformer();
                user = transformer.Transform(dbUser);
            }
            return(user);
        }
Exemplo n.º 9
0
        public ChurchReview Create(ChurchReview model)
        {
            var churchReview = new ChurchReview();

            using (var sp = new StoredProcedure("spInsertChurchReview"))
            {
                sp.SqlCommand.Parameters.AddWithValue("@userID", model.UserId);
                sp.SqlCommand.Parameters.AddWithValue("@simbahanID", model.SimbahanId);
                sp.SqlCommand.Parameters.AddWithValue("@title", model.Title);
                sp.SqlCommand.Parameters.AddWithValue("@rate", model.StarCount);
                sp.SqlCommand.Parameters.AddWithValue("@content", model.Comment);

                var reader = sp.SqlCommand.ExecuteReader();

                while (reader.Read())
                {
                    churchReview          = _churchReviewTransformer.Transform(reader);
                    churchReview.User     = _userTransformer.Transform(reader);
                    churchReview.Simbahan = _churchTransformer.Transform(reader);
                }
            }

            return(churchReview);
        }
Exemplo n.º 10
0
        public List <CSUser> GetUsersByCompanyId(int companyId)
        {
            List <CSUser> users = null;

            using (var db = new ManagementToolEntities())
            {
                var resp    = new UsersRepository(db);
                var dbUsers = resp.GetAllUsersInCompany(companyId);
                if (dbUsers != null && dbUsers.Count() > 0)
                {
                    UserTransformer transformer = new UserTransformer();
                    users = transformer.Transform(dbUsers);
                }
            }

            return(users);
        }
Exemplo n.º 11
0
        public List <Tuple <ChurchInfo, User> > GetChurchFollowers(int churchId)
        {
            var churchTransformer = new ChurchTransformer();
            var userTransformer   = new UserTransformer();
            var followers         = new List <Tuple <ChurchInfo, User> >();

            using (var dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString))
            {
                if (dbconn.State == ConnectionState.Open)
                {
                    dbconn.Close();
                }
                dbconn.Open();

                using (var cmd = new SqlCommand("spGetChurchFollowers", dbconn))
                {
                    try
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@churchID", churchId);


                        var reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            var church   = churchTransformer.Transform(reader);
                            var user     = userTransformer.Transform(reader);
                            var follower = new Tuple <ChurchInfo, User>(church, user);

                            followers.Add(follower);
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }

            return(followers);
        }
Exemplo n.º 12
0
        public User Update(int id, User model)
        {
            var user = new User();

            using (var dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString))
            {
                if (dbconn.State == ConnectionState.Open)
                {
                    dbconn.Close();
                }
                dbconn.Open();

                using (var cmd = new SqlCommand("spUpdateUserInformation", dbconn))
                {
                    try
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@userId", id);
                        cmd.Parameters.AddWithValue("@firstName", model.FirstName);
                        cmd.Parameters.AddWithValue("@lastName", model.LastName);
                        cmd.Parameters.AddWithValue("@gender", model.Gender);
                        cmd.Parameters.AddWithValue("@birthday", model.DateOfBirth);


                        var reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            user = _userTransformer.Transform(reader);
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }

            return(user);
        }
Exemplo n.º 13
0
        public User Update(int id, User model)
        {
            var user = new User();

            using (var sp = new StoredProcedure("spUpdateUserInformation"))
            {
                sp.SqlCommand.Parameters.AddWithValue("@userId", id);
                sp.SqlCommand.Parameters.AddWithValue("@firstName", model.FirstName);
                sp.SqlCommand.Parameters.AddWithValue("@lastName", model.LastName);
                sp.SqlCommand.Parameters.AddWithValue("@gender", model.Gender);
                sp.SqlCommand.Parameters.AddWithValue("@birthday", model.DateOfBirth);

                var reader = sp.SqlCommand.ExecuteReader();

                while (reader.Read())
                {
                    user = _userTransformer.Transform(reader);
                }
            }

            return(user);
        }
Exemplo n.º 14
0
        public List <Tuple <Church, User> > GetChurchFollowers(int churchId)
        {
            var churchTransformer = new ChurchTransformer();
            var userTransformer   = new UserTransformer();
            var followers         = new List <Tuple <Church, User> >();

            using (var sp = new StoredProcedure(""))
            {
                sp.SqlCommand.Parameters.AddWithValue("@churchID", churchId);

                var reader = sp.SqlCommand.ExecuteReader();

                while (reader.Read())
                {
                    var church   = churchTransformer.Transform(reader);
                    var user     = userTransformer.Transform(reader);
                    var follower = new Tuple <Church, User>(church, user);

                    followers.Add(follower);
                }
            }

            return(followers);
        }
Exemplo n.º 15
0
        public SaintReflection GetUserReflection(int userId, int saintId)
        {
            var saintReflection = new SaintReflection();

            using (var dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString))
            {
                if (dbconn.State == ConnectionState.Open)
                {
                    dbconn.Close();
                }
                dbconn.Open();

                using (var cmd = new SqlCommand("spGetUserDailySaintReflection", dbconn))
                {
                    try
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@userID", userId);
                        cmd.Parameters.AddWithValue("@saintID", saintId);


                        var reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            saintReflection       = _saintReflectionTransformer.Transform(reader);
                            saintReflection.Saint = _saintTransformer.Transform(reader);
                            saintReflection.User  = _userTransformer.Transform(reader);
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }

            return(saintReflection);
        }