/// <summary> /// Registers a prospect. /// </summary> /// <param name="prospect">The prospect.</param> /// <returns>Status.</returns> /// <exception cref="System.ArgumentNullException">prospect</exception> public async Task <Status> RegisterProspect(Prospect prospect) { if (prospect == null) { throw new ArgumentNullException("prospect"); } var prospectDto = new ProspectDto { DsrPhone = prospect.DsrPhone, FirstName = prospect.FirstName, LastName = prospect.LastName, Phone = prospect.Phone, Means = prospect.Money, Authority = prospect.Authority, Need = prospect.Need }; Status status = null; StatusDto statusDto = await api.RegisterProspect(prospectDto); if (statusDto != null) { status = new Status { Success = statusDto.Successful, Text = statusDto.ResponseText }; } return(status); }
public async Task <ActionResult <ProspectDto> > AddProspect(ProspectDto dto) { if (dto == null) { return(BadRequest("Prospect does not exist.")); } Company company = new Company() { CompanyId = Guid.NewGuid().ToString(), CompanyName = dto.CompanyName, CompanyCountry = dto.CompanyCountry, CompanyZip = dto.CompanyZip, Registered = DateTime.Now, NumberOfEmployees = dto.NumberOfEmployees, CreatorId = dto.CreatorId }; Offer offer = new Offer() { OfferId = Guid.NewGuid().ToString(), Registered = DateTime.Now, FromCity = dto.FromCity, FromCountry = dto.FromCountry, FromZip = dto.FromZip, ToCity = dto.ToCity, ToCountry = dto.ToCountry, ToZip = dto.ToZip, Text = dto.Text, Solution = dto.Solution, Company = company, CreatorId = dto.CreatorId }; _companyRepository.AddCompany(company); await _companyRepository.SaveAllAsync(); _offerRepository.AddOffer(offer); await _offerRepository.SaveAllAsync(); var offerDto = _mapper.Map <OfferDto>(offer); await _hub.Clients.All.SendAsync("NewOffer", offerDto); return(Ok(dto)); }
public async Task <StatusDto> RegisterProspect(ProspectDto prospect) { string url = baseUrl + "prospects"; Log.Verbose("RegisterProspect: " + url); var request = prospect; string json = JsonConvert.SerializeObject(request); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = null; response = await client.PostAsync(url, content); StatusDto statusDto = null; if (response.IsSuccessStatusCode) { statusDto = JsonConvert.DeserializeObject <StatusDto>(await response.Content.ReadAsStringAsync()); } return(statusDto); }