コード例 #1
0
        public async Task AddRandomAsync()
        {
            var contact = _fakeDataService.GenerateComplex <Contact>();

            contact.UserId = Guid.Parse("9f8a5487-3acf-4eb9-96cf-6b8b0b8da526");
            await _contactService.AddAsync(contact);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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)));
        }
コード例 #4
0
        // 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"));
        }
コード例 #5
0
            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);
            }
コード例 #6
0
        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));
        }
コード例 #7
0
        public async Task <IActionResult> PostAsync(
            [FromBody] SaveContactResource saveContactResource)
        {
            var response = await _contactService.AddAsync(saveContactResource);

            if (!response.Success)
            {
                return(BadRequest(response));
            }

            return(Ok(response));
        }
コード例 #8
0
        private async void AddHandler()
        {
            IsBusy = true;
            var newContact = await _contactCreator
                             .CreateContact();

            await _contactService.AddAsync(newContact);

            await LoadAsync();

            IsBusy = false;
        }
コード例 #9
0
        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. "));
        }
コード例 #10
0
        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());
        }
コード例 #11
0
        //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));
        }
コード例 #12
0
        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()));
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        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"
                }));
            }
        }
コード例 #15
0
        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"));
        }
コード例 #16
0
        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."));
        }
コード例 #17
0
        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)));
        }