예제 #1
0
        public async Task <IActionResult> EditApplication(EditApplication editApplication)
        {
            var uri = new Uri(Consts.appAdress + "api/ApiApplication/UpdateApplication");

            using (var httpClient = new HttpClient())
            {
                if (ModelState.IsValid)
                {
                    var requestBody = new StringContent(JsonConvert.SerializeObject(editApplication), Encoding.UTF8, "application/json");
                    var response    = await _httpClient.PostAsync(uri, requestBody);

                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        ViewBag.JavaScriptToRun = "AddNotification(function () { window.location.href = '/Application/ApplicationDetails?applicationId=" + editApplication.ApplicationId + "';}, 'Pomyślnie zaktualizowano zgłoszenie'); ";
                        return(View(editApplication));
                    }
                    else
                    {
                        return(View());
                    }
                }
                else
                {
                    return(View(editApplication));
                }
            }
        }
예제 #2
0
 private void OnCreateApplicationButtonClick(object sender, RoutedEventArgs e)
 {
     if (NavigationService != null)
     {
         NavigationService.Navigate(
             new Uri(string.Format("Req/EditApplication?FolderId={0}", FolderId),
                     UriKind.Relative));
     }
     else
     {
         Content = new EditApplication {
             OrgId = string.Empty, FolderId = FolderId, BackUrl = "Browser"
         };
     }
 }
예제 #3
0
        public async Task <IActionResult> EditApplication(int applicationId)
        {
            ViewBag.ApplicationId = applicationId;
            var userId       = User.Claims.FirstOrDefault(x => x.Type == "Id").Value;
            var uriIsUserApp = new Uri(Consts.appAdress + "api/ApiApplication/IsUserApp/" + applicationId + "/" + userId);

            try
            {
                var response = await _httpClient.GetAsync(uriIsUserApp);

                var resultContent = Convert.ToBoolean(await response.Content.ReadAsStringAsync());
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    if (resultContent)
                    {
                        ViewBag.IsUserApp = "userApp";
                    }
                }
                else
                {
                    Redirect("~/Home/NoPermisions");
                }

                /// dowload application details
                var uri = new Uri(Consts.appAdress + "api/ApiApplication/GetApplicationToEdit/" + applicationId);

                using (HttpClient _httpClient = new HttpClient())
                {
                    var responseDetails = await _httpClient.GetAsync(uri);

                    if (responseDetails.StatusCode == HttpStatusCode.OK)
                    {
                        EditApplication model = JsonConvert.DeserializeObject <EditApplication>(await responseDetails.Content.ReadAsStringAsync());
                        return(View(model));
                    }
                    else
                    {
                        return(View());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
        public async Task UpdateApplication(EditApplication applicationDto)
        {
            var appTmp = await _context.Applications
                         .Include(x => x.Adress)
                         .Include(x => x.Adress.Geolocation)
                         .FirstOrDefaultAsync(x => x.ApplicationId == applicationDto.ApplicationId);

            appTmp.CategoryId    = applicationDto.CategoryId;
            appTmp.Description   = applicationDto.Description;
            appTmp.Title         = applicationDto.Title;
            appTmp.Adress.CityId = applicationDto.CityId;
            appTmp.Adress.Street = applicationDto.Street;
            appTmp.Adress.Geolocation.Latitude  = applicationDto.Latitude;
            appTmp.Adress.Geolocation.Longitude = applicationDto.Longitude;

            await _context.SaveChangesAsync();
        }
예제 #5
0
        private void OnCreateApplicationButtonClick(object sender, RoutedEventArgs e)
        {
            string orgId = OrgId;

            if (string.IsNullOrEmpty(orgId))
            {
                orgId = AuthenticateStatus.DefaultOrganization;
            }
            if (NavigationService != null)
            {
                NavigationService.Navigate(
                    new Uri(string.Format("Req/EditApplication?OrgId={0}&FolderId={1}", orgId, FolderId),
                            UriKind.Relative));
            }
            else
            {
                Content = new EditApplication {
                    OrgId = orgId, FolderId = FolderId, BackUrl = "Browser"
                };
            }
        }
예제 #6
0
 private async void TSB_EditApplication_Click(object sender, EventArgs e)
 {
     await EditApplication?.Invoke();
 }
예제 #7
0
 public async Task UpdateApplication([FromBody] EditApplication application)
 {
     await _applicationService.UpdateApplication(application);
 }