//Обработка события нажатия на кнопку добавить public void AboutAddClick(Clientas client) { AddApplication application = new AddApplication(client, mngRiealtorAgency.Agency); application.Owner = window; application.ShowDialog(); }
public Boolean AddApplication(AddApplication application) { var callUri = String.Format( "{0}/api/applications/{1}", _baseConfigurationServer, application.ApplicationName); var result = _environment.ExecuteRequest(callUri, application, "PUT"); var resultObject = (JObject)JsonConvert.DeserializeObject(result); return(resultObject["success"].Value <Boolean>()); }
public async Task <IActionResult> AddNew(AddApplication addApplication) { addApplication.UserId = Convert.ToInt32(User.Claims.Where(x => x.Type == "Id").FirstOrDefault().Value); var photos = addApplication.Photos; addApplication.Photos = null; var uri = new Uri(Consts.appAdress + "api/ApiApplication/Add"); var uriPhoto = new Uri(Consts.appAdress + "api/ApiApplication/AddPhotos/"); HttpResponseMessage responsePhoto; using (var httpClient = new HttpClient()) { if (ModelState.IsValid) { var requestBody = new StringContent(JsonConvert.SerializeObject(addApplication), Encoding.UTF8, "application/json"); var response = await _httpClient.PostAsync(uri, requestBody); HttpContent noPhoto = new StringContent("noPhoto", Encoding.UTF8, "application/json"); if (response.StatusCode == HttpStatusCode.OK) { var applicationId = response.Content.ReadAsStringAsync(); var form = new MultipartFormDataContent(); if (photos != null) { foreach (var photo in photos) { var fileStream = photo.OpenReadStream(); form.Add(new StreamContent(fileStream), "file", photo.FileName); } responsePhoto = await httpClient.PostAsync(uriPhoto + applicationId.Result, form); } else { responsePhoto = await httpClient.PostAsync(uriPhoto + applicationId.Result, noPhoto); } if (responsePhoto.StatusCode == HttpStatusCode.OK) { ViewBag.JavaScriptToRun = "AddNotification(function () { window.location.href = '/Application/AddNew';}, 'Pomyślnie dodano zgłoszenie'); "; return(View()); } else { return(View()); } //else // ViewBag.JavaScriptToRun = "itemAddNotification(function () { window.location.href = '/Application/AddNew';}); "; // return View(); } } return(View()); } }
private void MapToHotelApp(HotelApplication ha, AddApplication model, Hotel h, Application app) { ha.ApplicationId = app.ApplicationId; ha.ApplicationName = app.Name; ha.Cost = model.Cost; ha.EndDate = model.EndDate; ha.StartDate = model.StartDate; ha.HotelId = h.HotelId; ha.HotelName = h.Name; Maintenance m = new Maintenance(model.MStartDate, model.MEndDate, model.MaintenanceCost); ha.Maintenance = m; }
public Object AddApplication( [FromBody] AddApplication model, String appName) { var redirectFile = GetApplicationRedirectFileName(appName); var directoryConfig = GetApplicationDirectory(appName); if (File.Exists(redirectFile) || Directory.Exists(directoryConfig)) { return(new { success = false, error = "Application was already created" }); } File.WriteAllText(redirectFile, model.RedirectFolder); return(new { success = true }); }
public ActionResult Add() { string userID = User.Identity.GetUserId(); if (string.IsNullOrEmpty(userID)) { return(RedirectToAction("Login", "Account")); } else { AddApplication viewmodel = new AddApplication(); viewmodel.Volunteers = db.Volunteers.ToList(); viewmodel.VolunteerPostings = db.VolunteerPostings.ToList(); return(View(viewmodel)); } }
public async Task <int> AddApplication(AddApplication applicationDto) { Application application; try { Geolocation geolocation = new Geolocation { Latitude = applicationDto.Latitude, Longitude = applicationDto.Longitude }; await _context.Geolocations.AddAsync(geolocation); await _context.SaveChangesAsync(); Adress adress = new Adress { CityId = applicationDto.CityId, Street = applicationDto.Street, GeolocationId = geolocation.GeolocationId }; await _context.Adresses.AddAsync(adress); await _context.SaveChangesAsync(); application = _mapper.Map <AddApplication, Application>(applicationDto); application.AdressId = adress.AdressId; application.StatusId = 1; application.Title = await _textControlService.CensorText(application.Title); application.Description = await _textControlService.CensorText(application.Description); } catch (Exception ex) { throw ex; } try { await _context.Applications.AddAsync(application); await _context.SaveChangesAsync(); return(application.ApplicationId); } catch (Exception ex) { throw ex; } }
public void Verify_error_when_application_is_already_present() { var applicationResult = client.DownloadString(baseUri + "/status"); JObject jobjAppResults = (JObject)JsonConvert.DeserializeObject(applicationResult); var applications = ((JArray)jobjAppResults["Applications"]).Select(t => t.Value <String>()).ToList(); var existingApp = applications.First(); AddApplication parameter = new AddApplication() { ApplicationName = existingApp, RedirectFolder = @"C:\temp\test\" + existingApp }; var serializedParameter = JsonConvert.SerializeObject(parameter); var result = client.DownloadString( baseUri + "/api/applications/" + existingApp, serializedParameter, "PUT"); JObject jobj = (JObject)JsonConvert.DeserializeObject(result); Assert.That((Boolean)jobj["success"], Is.EqualTo(false), "Operation should file because application already exists"); }
public void verify_registration_of_new_application() { var newId = Guid.NewGuid().ToString(); AddApplication parameter = new AddApplication() { ApplicationName = newId, RedirectFolder = @"C:\temp\test\" + newId }; var serializedParameter = JsonConvert.SerializeObject(parameter); var result = client.DownloadString( baseUri + "/api/applications/" + newId, serializedParameter, "PUT"); JObject jobj = (JObject)JsonConvert.DeserializeObject(result); Assert.That((Boolean)jobj["success"], Is.EqualTo(true), "Operation completed with errors"); var applicationResult = client.DownloadString(baseUri + "/status"); JObject jobjAppResults = (JObject)JsonConvert.DeserializeObject(applicationResult); var applications = ((JArray)jobjAppResults["Applications"]).Select(t => t.Value <String>()).ToList(); Assert.That(applications.Contains(newId), "Application was not correctly created"); }
public void Verify_error_when_application_is_created_two_times() { var newId = Guid.NewGuid().ToString(); AddApplication parameter = new AddApplication() { ApplicationName = newId, RedirectFolder = @"C:\temp\test\" + newId }; var serializedParameter = JsonConvert.SerializeObject(parameter); var result = client.DownloadString( baseUri + "/api/applications/" + newId, serializedParameter, "PUT"); JObject jobj = (JObject)JsonConvert.DeserializeObject(result); Assert.That((Boolean)jobj["success"], Is.EqualTo(true), "Operation completed with errors"); result = client.DownloadString( baseUri + "/api/applications/" + newId, serializedParameter, "PUT"); jobj = (JObject)JsonConvert.DeserializeObject(result); Assert.That((Boolean)jobj["success"], Is.EqualTo(false), "Operation completed with errors"); }
public ActionResult Add(AddApplication command) { CommandDispatcher.Dispatch(command); return(Created($"applications/{command.ApplicationName}", null)); }
private async void TSB_AddApplication_Click(object sender, EventArgs e) { await AddApplication?.Invoke(); }
public async Task <int> Add([FromBody] AddApplication application) { return(await _applicationService.AddApplication(application)); }
//методы public AddApplicationController(AddApplication window) { this.window = window; }