public async Task <APIResponse <Contact> > UpdateContact(string Id, ContactInput input) { Contact contact = await _contactRepo.GetByIdAsync(Id); if (contact == null) { return new APIResponse <Contact>() { Code = "400", Data = contact, Message = "Not Found!", OK = false } } ; contact.Name = input.Name; contact.MobilePhone = input.MobilePhone; contact.Phone = input.Phone; contact.Email = input.Email; contact.Address = input.Address; contact.Updated = DateTime.Now; contact = await _contactRepo.UpdateAsync(Id, contact); return(new APIResponse <Contact>() { Code = "200", Data = contact, Message = "Success", OK = true }); } }
public async Task <APIResponse <Contact> > AddContact(ContactInput input) { Contact contact = new Contact { Address = input.Address, Email = input.Email, Name = input.Name, Phone = input.Phone, MobilePhone = input.MobilePhone }; Contact IsExist = await _contactRepo.GetAsync(x => x.Name == contact.Name); if (IsExist != null) { return new APIResponse <Contact>() { Code = "400", Data = null, Message = "There is already contact with the same name!", OK = false } } ; Contact newContact = await _contactRepo.AddAsync(contact); return(new APIResponse <Contact>() { Code = "200", Data = newContact, Message = "Success", OK = true }); }
/// <summary> /// Performs execution of the command /// </summary> protected override void ProcessRecord() { // Instantiate a new NebContactInput from the provided parameters ContactInput contactInput = new ContactInput(); contactInput.UserGuid = Guid; contactInput.Primary = Primary.IsPresent; contactInput.CommunicationMethod = CommunicationMethod; // return it back to the pipeline WriteObject(contactInput); }
public async Task <IActionResult> Post(ContactInput model) { _logger.LogDebug($"Creating a new contact with Email \"{model.Email}\""); var contact = new Contact(); model.MapToContact(contact); await _contactRepository.Create(contact); return(CreatedAtAction(nameof(GetById), "contact", new { id = contact.Id }, contact)); }
public async Task <IActionResult> ContactingAdmin(ContactInput input) { if (ModelState.IsValid) { await this.emailSender.SendEmailAsync("", $"{input.Tbname} contacted you via the Contact us page with an e-mail {input.Tbemail}.", input.Message); return(Ok()); } else { return(BadRequest()); } }
public async Task <IActionResult> Put(int id, ContactInput model) { _logger.LogDebug($"Updating a contact with id {id}"); var contact = await _contactRepository.GetById(id); if (contact == null) { return(NotFound()); } model.MapToContact(contact); await _contactRepository.Update(id, contact); return(Ok(contact)); }
public APIResponse <Contact> UpdateContact(string Id, [FromBody] ContactInput input) { return(_contactService.UpdateContact(Id, input).Result); }
public APIResponse <Contact> Add([FromBody] ContactInput data) { return(_contactService.AddContact(data).Result); }