Exemple #1
0
        public async Task <IActionResult> MinistryArmDetails(int ministryArmId)
        {
            var           requestUrl    = $"{BaseUrl}{apiUriMinistryArms}/GetMinistryArm?ministryArmId={ministryArmId}";
            MinistryArmVM ministryArmVm = new MinistryArmVM(_configuration);

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(requestUrl);
                HttpResponseMessage result = await client.GetAsync(requestUrl);

                if (result.StatusCode == HttpStatusCode.OK)
                {
                    ministryArmVm.MinistryArmDTO = await result.Content.ReadAsAsync <MinistryArmDTO>();
                }
                else
                {
                    ministryArmVm.OutputHandler = await result.Content.ReadAsAsync <OutputHandler>();
                }
            };

            if (ministryArmVm.MinistryArmDTO.MinistryArmAbbreviation == null)
            {
                ministryArmVm.PageSetup.PageTitle = ministryArmVm.MinistryArmDTO.MinistryArmName;
            }
            else
            {
                ministryArmVm.PageSetup.PageTitle = $"{ministryArmVm.MinistryArmDTO.MinistryArmName}({ministryArmVm.MinistryArmDTO.MinistryArmAbbreviation})";
            }
            ministryArmVm.MinistryArmDTO.OldImageUrl = ministryArmVm.MinistryArmDTO.Artwork;
            return(View(ministryArmVm));
        }
Exemple #2
0
        public async Task <IActionResult> ManageMinistryArms(bool isDeleteFailed, string error)
        {
            var user = await StaticDataHandler.GetSessionDetails();

            //send admin = true to avoid looping which converts files to bytes, we don't need it here.
            //True means this request has been generated by an individual with admin privileges from the Admin Portal, so the API handles the request as an admin request
            var           requestUrl    = $"{BaseUrl}{apiUriMinistryArms}/GetMinistryArms?isAdminRequest={true}";
            MinistryArmVM ministryArmVM = new MinistryArmVM(_configuration);

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(requestUrl);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", user.Token);
                HttpResponseMessage response = await client.GetAsync(requestUrl);

                OutputHandler outputHandler = new OutputHandler();
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    if (isDeleteFailed) //This is coming from delete function if anything wrong happens there, throw error
                    {
                        outputHandler.IsErrorOccured = true;
                        if (string.IsNullOrEmpty(error))
                        {
                            outputHandler.Message = "Something went wrong, Delete failed. Check if related records exist e.g events or Media";
                        }
                        else
                        {
                            outputHandler.Message = error;
                        }
                    }

                    ministryArmVM.OutputHandler    = outputHandler;
                    ministryArmVM.MinistryArmsList = await response.Content.ReadAsAsync <IEnumerable <MinistryArmDTO> >();
                }
                else if (response.StatusCode == HttpStatusCode.Unauthorized)
                {
                    ministryArmVM.OutputHandler.IsErrorOccured = true;
                    ministryArmVM.OutputHandler.Message        = "You're not Authorized to perfom this task";
                }
                else
                {
                    outputHandler.IsErrorOccured = false;
                };
            };
            //sermons.SermonCategories = await StaticDataHandler.GetSermonCategory(BaseUrl);
            return(View(ministryArmVM));
        }
Exemple #3
0
        public async Task <IActionResult> Index()
        {
            var           requestUrl   = $"{BaseUrl}{apiUriMinistryArms}/GetMinistryArms";
            MinistryArmVM ministrArmVM = new MinistryArmVM(_configuration);

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(requestUrl);
                HttpResponseMessage response = await client.GetAsync(requestUrl);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    ministrArmVM.MinistryArmsList = await response.Content.ReadAsAsync <IEnumerable <MinistryArmDTO> >();
                }
                ;
            };
            return(View(ministrArmVM));
        }