Exemplo n.º 1
0
        private MessageModule LoadMessageModule()
        {
            var messageModule = new MessageModule();

            int churchId = _session?.ChurchId ?? 3; // default to Graham
            var param    = new GetCorrespondenceParameter(churchId, (int)MessageType.TextMessage, 100);

            // The Web Api GET method needs to be changed to remove the body from the message, and use query string instead
            //var correspondence = SubmitRequest<GetCorrespondenceParameter>("/api/message/GetCorrespondence", param);
            //var correspondence = await _apiProvider.GetItemAsync<GetCorrespondenceParameter>(Request, "/api/message/GetCorrespondence", mp);
            var correspondence = "";

            var list = _apiProvider.DeserializeJson <List <Correspondence> >(correspondence);

            messageModule.CorrespondenceList = list.Select <Correspondence, CorrespondenceVm>(c => new CorrespondenceVm(c)).ToList();

            var groups = SubmitRequest <int>("/api/message/GetGroups", churchId);
            var grps   = _apiProvider.DeserializeJson <List <RecipientGroup> >(groups);

            messageModule.GroupList = grps.Select <RecipientGroup, GroupVm>(c => new GroupVm(c)).ToList();

            //messageModule.MessageList
            int memberID = list.FirstOrDefault()?.ID ?? 0; // most received correspondence

            messageModule.MessageList = LoadMessageList(memberID);

            return(messageModule);
        }
Exemplo n.º 2
0
        //[VerifySessionAttribute]
        public async Task <ActionResult> Index(string statusIds, int page = 1, int pageSize = 1000)
        {
            try
            {
                InitSession();

                var queryString = $"churchId={_session.ChurchId}&statusIds={statusIds}&page={page}&pageSize={pageSize}";
                var result      = await _apiProvider.GetItemAsync(_uri, queryString);

                var list = _apiProvider.DeserializeJson <List <cm.Member> >(result);

                var metajson = await _apiProvider.GetItemAsync($"{_uri}/metadata", $"churchId={_session.ChurchId}");

                var metaList = _apiProvider.DeserializeJson <List <AppEnum> >(metajson);

                var churchjson = await _apiProvider.GetItemAsync("church/" + _session.ChurchId);

                var church = _apiProvider.DeserializeJson <Church>(churchjson);

                var viewModel = new MemberIndexViewModel()
                {
                    MemberList = list, MetaList = metaList
                };
                viewModel.Title = $"{church.Name} Member List";

                return(View(viewModel));
            }
            catch (Exception ex)
            {
                return(Content("Error loading Member list: " + ex.Message));
            }
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Index()
        {
            try
            {
                var loginVm = new LoginVm();

                var json = await _apiProvider.GetItemAsync("church", "page=1&pageSize=10000&showAll=false");

                loginVm.ChurchList = _apiProvider.DeserializeJson <List <ChurchVm> >(json);

                var loginEmail = Request.Cookies["email"];
                if (loginEmail != null)
                {
                    loginVm.Email    = loginEmail.Value;
                    loginVm.Remember = true;
                }

                var churchId = Request.Cookies["churchId"];
                if (churchId != null)
                {
                    loginVm.ChurchId = Convert.ToInt32(churchId.Value);
                }

                var password = Request.Cookies["password"];
                if (password != null)
                {
                    loginVm.Password = password.Value;
                }

                if (TempData["loginError"] != null)
                {
                    ModelState.AddModelError("loginError", TempData["loginError"].ToString());
                }

                return(View("/Views/Account/Login.cshtml", loginVm));
            }catch (Exception ex)
            {
                return(Content("The following error occurred while trying to load the login page:  " + ex.Message));
            }
        }
Exemplo n.º 4
0
        //[VerifySessionAttribute]
        public async Task <ActionResult> Index()
        {
            InitSession();

            var result = await _apiProvider.GetItemAsync(_uri, "page=1&pageSize=100");

            var list = _apiProvider.DeserializeJson <List <cm.Church> >(result);

            var metajson = await _apiProvider.GetItemAsync($"{_uri}/metadata");

            var metaList = _apiProvider.DeserializeJson <List <AppEnum> >(metajson);

            var viewModel = new ChurchIndexViewModel()
            {
                ChurchList = list, MetaList = metaList
            };

            return(View(viewModel));
        }