public async Task AddRandomAsync() { var contact = _fakeDataService.GenerateComplex <Contact>(); contact.UserId = Guid.Parse("9f8a5487-3acf-4eb9-96cf-6b8b0b8da526"); await _contactService.AddAsync(contact); }
public async Task <IActionResult> Post([FromBody] ContactCreateModel model) { var contactDto = _mapper.Map <ContactCreateDto>(model); var contact = await _contactService.AddAsync(contactDto); return(CreatedAtRoute("Get", new { id = contact.Id }, contact)); }
public async Task <IActionResult> AddAsync(Contact contact) { var result = await _contactService.AddAsync(contact); if (result.Success) { return(Ok(JsonConvert.SerializeObject(result.Message))); } return(BadRequest(JsonConvert.SerializeObject(result.Message))); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } await _contacts.AddAsync(ContactDto); return(RedirectToPage("./Index")); }
public async Task <bool> Handle(CreateContactCommand request, CancellationToken cancellationToken) { var contact = _mapper.Map <Contact>(request.ContactDto); var contactSaved = false; if (contact != null) { contactSaved = await _contactService.AddAsync(contact); } return(contactSaved); }
public async Task <IActionResult> Create([Bind("Name,Email,PhoneNumber,Domain,Notes")] Contact contact) { if (ModelState.IsValid) { await _contactService.AddAsync(contact); await _clearbitServiceProvider.EnrichmentContact(contact); return(RedirectToAction(nameof(Index))); } return(View(contact)); }
public async Task <IActionResult> PostAsync( [FromBody] SaveContactResource saveContactResource) { var response = await _contactService.AddAsync(saveContactResource); if (!response.Success) { return(BadRequest(response)); } return(Ok(response)); }
private async void AddHandler() { IsBusy = true; var newContact = await _contactCreator .CreateContact(); await _contactService.AddAsync(newContact); await LoadAsync(); IsBusy = false; }
public async Task <IActionResult> Send(ContactSendDto contactSendDto) { if (!ModelState.IsValid) { return(View().ShowMessage(Status.Error, "Hata", "Eksik veya hatalı bilgiler mevcut!")); } await _contactService.AddAsync(_mapper.Map <Contact>(contactSendDto)); return(RedirectToAction("Index", "Home").ShowMessage(Status.Ok, "Başarılı", "Mesajınız başarıyla iletilmiş olup en kısa sürede değerlendirilecektir. ")); }
public async Task <IActionResult> Create(ContactForCreateVM contactForCreateVM) { var mappedContact = _mapper.Map <IContactForCreateDto>(contactForCreateVM); var result = await _contactService.AddAsync(mappedContact); if (!result.Success) { return(BadRequest(result.Message)); } return(Ok()); }
//TODO: move to web API for real applications public async Task <JsonResult> AddMessage(ContactFormViewModel form) { //TODO: add validation await _contactService.AddAsync(form.Name, form.Email, form.Message); //TODO: create model for result and convert to json //return Content("Success"); var result = new JsonResultModel() { Success = true, Message = "Success! Your message has beent sent." }; return(Json(result)); }
public async Task <IActionResult> AddContact([FromBody] ContactDto contactDto) { if (contactDto == null) { return(NoContent()); } Contact contact = await _contactService.AddAsync(contactDto.ToNewContact()); if (contact == null) { _logger.LogError("New contact not created"); _logger.LogDebug("ContactDto is {0}", Newtonsoft.Json.JsonConvert.SerializeObject(contactDto)); return(NotFound()); } return(CreatedAtAction(nameof(GetContact), contact.ToContactDto())); }
public async Task <IHttpActionResult> PostContact(ContactDto contactDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Contact contact = new Contact(); Mapper.Map(contactDto, contact); contact.ApplicationUserId = User.Identity.GetUserId(); contact = await _contactService.AddAsync(contact); contactDto.Id = contact.Id; return(CreatedAtRoute("ApiRoute", new { id = contactDto.Id }, contactDto)); }
public async Task <ActionResult> PostAsync([FromBody] Contacts item) { if (!ModelState.IsValid) { return(BadRequest()); } try { var exist = await service.GetAsync(x => x.email == item.email); if (exist != null) { return(Conflict(new Response() { Status = false, Description = "Duplicate record" })); } var result = await service.AddAsync(item); if (result) { var newitem = await service.GetAsync(x => x.email == item.email); return(StatusCode(201, newitem)); } else { return(BadRequest()); } } catch (Exception ex) { logger.LogError(ex.Message); return(StatusCode(500, new Response() { Status = false, Description = "System error" })); } }
public async Task <IActionResult> ContactAsync(AddContactViewModel model) { // Retrieve the storage account from the connection string. CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("DefaultEndpointsProtocol=https;AccountName=devcodeandcloud;AccountKey=9LhuuclWYiF5Oisb20idnhr8omIrghiGG8E4neyptO3MmXSRmjwVULkJslfzY4omSSdenU9ZS+0A8sv6XXsQtQ==;EndpointSuffix=core.windows.net")); // Create the queue client. CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); // Retrieve a reference to a queue. CloudQueue queue = queueClient.GetQueueReference("myqueue"); // Create the queue if it doesn't already exist. await queue.CreateIfNotExistsAsync(); // Create a message and add it to the queue. CloudQueueMessage message = new CloudQueueMessage(model.Email); await queue.AddMessageAsync(message); _service.AddAsync(model); return(View("Contact")); }
public async Task <IActionResult> Compose(ContactComposeDto contactSendDto) { if (!ModelState.IsValid) { return(View(contactSendDto).ShowMessage(Status.Error, "Hata", "Eksik veya hatalı bilgiler mevcut!")); } try { var body = new StringBuilder(); body.AppendLine($"Konu: {contactSendDto.Subject}"); body.AppendLine($"Mesaj: {contactSendDto.Message}"); SendMail.MailSender($"BerendBebe - {contactSendDto.Subject}", body.ToString(), contactSendDto.EmailAdress); var contact = _mapper.Map <Contact>(contactSendDto); await _contactService.AddAsync(contact); } catch (Exception) { return(View(contactSendDto).ShowMessage(Status.Error, "Hata", "Mail gönderme işlemi sırasında hata oluştu!")); } return(RedirectToAction("Index").ShowMessage(Status.Ok, "Başarılı", "Mail başarıyla gönderildi.")); }
public async Task <IActionResult> AddNewContact([FromBody] ContactPostDto contactPostDto) { var contactResp = await contactService.AddAsync(contactPostDto); return(CreatedAtAction("GetClient", new { user1Id = contactResp.User1ID, user2Id = contactResp.User2ID }, mapper.Map <ContactResponseDto>(contactResp))); }