// POST: Contacts/Edit/{key} public ActionResult Edit(int id) { UpdateContact ViewModel = new UpdateContact(); string url = "contactsdata/findcontact" + id; HttpResponseMessage response = client.GetAsync(url).Result; //Can catch the status code (200 OK, 301 REDIRECT), etc. //Debug.WriteLine(response.StatusCode); if (response.IsSuccessStatusCode) { //Put data into contact data transfer object ContactDto SelectedContact = response.Content.ReadAsAsync <ContactDto>().Result; ViewModel.contact = SelectedContact; //get information about departments this contact belongs to. url = "departmentsdata/getdepartments"; response = client.GetAsync(url).Result; IEnumerable <DepartmentsDto> PotentialContact = response.Content.ReadAsAsync <IEnumerable <DepartmentsDto> >().Result; ViewModel.alldepartments = PotentialContact; return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }
public async Task <ResponseResult> UpdateContact(UpdateContact contact) { var contactUpdate = (await _contactRepo.GetAsync(x => x.ID == contact.ID)).FirstOrDefault(); if (contactUpdate == null) { return(new ResponseResult { Status = "NotExisted" }); } var checkExistedAnotherContact = await _contactRepo.ExistsAsync(x => x.ID != contact.ID && x.Name == contact.Name); if (checkExistedAnotherContact) { return(new ResponseResult { Status = "Existed" }); } contactUpdate.Name = contact.Name; contactUpdate.Address = contact.Address; await _contactRepo.UpdateAsync(contactUpdate); var result = _uow.Commit(); return(new ResponseResult { Status = result.ToString() }); }
public void UpdateContact(UpdateContact contact) { using (var servicePortClient = CustomerServicePortClient(GetBindingTransportCredentialOnly(), _userSettings.BaseUrl)) { servicePortClient.UpdateContact(contact); } }
public async Task <object> PUT(UpdateContact request) { var response = new BaseResponse(); var contactUp = new Contact { id = request.id, name = request.name, phoneNumber = request.phoneNumber, notes = request.notes, myFavourite = request.myFavourite, gender = request.gender, NetworkId = request.NetworkId, }; response.Results = await _contactService.Update(contactUp); if ((bool)response.Results == true) { response.Message = "Updated contact successfully"; } else { response.Message = "Updated contact failed"; } return(response); }
public int Update(UpdateContact contact) { Contact contactDto = _contactRepository.GetById(contact.Id); if (contactDto == null) { throw new NotFoundException(); } var contactByEmail = _contactRepository.GetByEmail(contact.Email); if (contactByEmail != null && contactByEmail.Id != contactDto.Id) { throw new DuplicateEmailException(); } var contactByPhone = _contactRepository.GetByPhoneNumber(contact.PhoneNumber); if (contactByPhone != null && contactByPhone.Id != contactDto.Id) { throw new DuplicatePhoneNumber(); } Contact updateContact = new Contact(contact.Id, contact.FirstName, contact.MiddleName, contact.LastName, contact.Email, contact.PhoneNumber, contact.Status, contactDto.CreatorRID, contact.ModifierRID); updateContact.CreationDate = contactDto.CreationDate; updateContact.ModificationDate = DateTime.UtcNow; _contactRepository.Update(updateContact); return(_contactRepository.SaveChanges()); }
public async Task <UpdateContact_Result> UpdateContactAsync(UpdateContact contact) { using (var servicePortClient = CustomerServicePortClient(GetBindingTransportCredentialOnly(), _userSettings.BaseUrl)) { return(await servicePortClient.UpdateContactAsync(contact)); } }
public object Any(UpdateContact request) { var contact = Db.SingleById <Contact>(request.Id); contact.PopulateWith(request); Db.Update(contact); return(contact); }
public HomeController() { _getContacts = new GetContacts(); _createContact = new CreateContact(); _updateContact = new UpdateContact(); _searchContact = new SearchContact(); _deleteContact = new DeleteContact(); }
public async Task <object> Put(UpdateContact request) { var result = await _iContactBusinessService.UpdateContact(request); return(new ResponseResult { Status = result.Status }); }
public HomeController() { _getContacts = new GetContacts(); _createContact = new CreateContact(); _updateContact = new UpdateContact(); _searchContact = new SearchContact(); _deleteContact = new DeleteContact(); //_context = new AddressBookContext(); }
public object Any(UpdateContact request) { if (!ContactServices.Contacts.TryGetValue(request.Id, out var contact) || contact.UserAuthId != this.GetUserId()) { throw HttpError.NotFound("Contact was not found"); } contact.PopulateWith(request); contact.ModifiedDate = DateTime.UtcNow; return(new UpdateContactResponse()); }
public ActionResult Create() { UpdateContact ViewModel = new UpdateContact(); //get information about department this person COULD contact. string url = "contactsdata/getcontacts"; HttpResponseMessage response = client.GetAsync(url).Result; IEnumerable <DepartmentsDto> PotentialContacts = response.Content.ReadAsAsync <IEnumerable <DepartmentsDto> >().Result; ViewModel.alldepartments = PotentialContacts; return(View(ViewModel)); }
//======================================= // // <Summary> // Method for Showing the Update // Contact Popup form // //======================================= private void ShowUpdateContact() { string studentNumber = ""; if (StudentRecords.CurrentRow.Index >= 0 && StudentRecords.CurrentRow.Cells[0] != null) { studentNumber = StudentRecords.CurrentRow.Cells[0].Value.ToString(); UpdateContact usc = new UpdateContact(studentNumber); if (usc.ShowDialog() == DialogResult.OK) { GetStudentContact(); } } }
public IActionResult UpdateContact([FromBody] UpdateContact contact) { if (!ModelState.IsValid) { return(BadRequest()); } int rows = _contactApplication.Update(contact); //if(rows == 0) //{ // return NotFound(); //} return(NoContent()); }
//================================ // <Summary> // Method for showing // Update Contact Modal // </Summary> //================================ private void ShowUpdateContactModal() { string studentNumber = StudentNumber.Text; if (studentNumber == "No Record") { studentNumber = ""; } if (studentNumber != "") { UpdateContact modal = new UpdateContact(studentNumber); modal.ShowDialog(); } else { MessageBox.Show("Please Search For student before updating the contact"); } }
public ActionResult Update(ContactViewModel model) { try { if (ModelState.IsValid) { CustomerService service = new CustomerService(_settings); UpdateContact contact = ContactViewModel.ViewModelToServiceModel(model); service.UpdateContact(contact); } return(View("Thanks")); } catch (Exception ex) { ViewBag.ErrorMessage = ex.Message; return(View(model)); } }
public object Post(UpdateContact contact) { return(new ContactResponse()); }
public async Task <IActionResult> UpdateContact(int contactId, [FromBody] UpdateContact contactToUpdate) { var response = await contactService.UpdateContact(contactId, contactToUpdate); return(response.ToHttpResponse()); }
public async Task <ActionResult <string> > Update(Contact contact) { var useCase = new UpdateContact(_efUoW); return(Ok(await useCase.Execute(contact))); }
public async Task <ISingleResponse <DtoContact> > UpdateContact(int contactId, UpdateContact contactToUpdate) { var response = new SingleResponse <DtoContact>(); var contactDbModel = await _contactRepository.GetAll().Where(x => x.Id == contactId).FirstOrDefaultAsync(); if (contactDbModel != null) { contactDbModel = _mapper.Map(contactToUpdate, contactDbModel); await _contactRepository.UpdateAsync(contactDbModel); response.Model = _mapper.Map <DtoContact>(contactDbModel); response.SetResponse(false, HttpResponseMessages.DATA_UPDATE_SUCCESS, HttpStatusCode.OK); } else { response.Model = null; response.SetResponse(true, HttpResponseMessages.NO_DATA_FOUND, HttpStatusCode.OK); } return(response); }
public HttpResponseMessage Put(int agreementId, int contactId, [FromBody] AgreementContactApiModel model) { model.Id = contactId; model.AgreementId = agreementId; var command = new UpdateContact(User); Mapper.Map(model, command); _updateHandler.Handle(command); var response = Request.CreateResponse(HttpStatusCode.OK, "Agreement contact was successfully updated."); return response; }