public static void Delete(Contact contact) { int index = AllContacts.FindIndex(x => x.Id == contact.Id); if (index >= 0) { AllContacts.RemoveAt(index); } }
public static void Update(Contact contact) { Contact toUpdate = AllContacts.Where(x => x.Id == contact.Id).FirstOrDefault(); if (toUpdate != null) { toUpdate.Name = contact.Name; toUpdate.Age = contact.Age; toUpdate.Telephone = contact.Telephone; } }
public Contact ImportContact(Contact contact) { ContactRepository.Add(contact); object fromFormsUrlEncoded; if (OperationContext.Current.IncomingMessageProperties.TryGetValue(FormUrlEncodedEnabledJsonEndpointFactory.FormUrlEncodedInputProperty, out fromFormsUrlEncoded)) { if ((bool)fromFormsUrlEncoded) { WebOperationContext.Current.OutgoingResponse.SuppressEntityBody = true; WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Redirect; // Start page is two levels up: domainservice.svc/JSON WebOperationContext.Current.OutgoingResponse.Headers[HttpResponseHeader.Location] = "../../SLAppTestPage.html"; } } return contact; }
public void RemoveContact(Contact contact) { ContactRepository.Delete(contact); }
public void UpdateContact(Contact contact) { ContactRepository.Update(contact); }
public void CreateContact(Contact contact) { ContactRepository.Add(contact); }
/// <summary> /// Asynchronously invokes the 'ImportContact' method of the DomainService. /// </summary> /// <param name="contact">The value for the 'contact' parameter of this action.</param> /// <returns>An operation instance that can be used to manage the asynchronous request.</returns> public InvokeOperation<Contact> ImportContact(Contact contact) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("contact", contact); this.ValidateMethod("ImportContact", parameters); return ((InvokeOperation<Contact>)(this.InvokeOperation("ImportContact", typeof(Contact), parameters, true, null, null))); }
/// <summary> /// Asynchronously invokes the 'ImportContact' method of the DomainService. /// </summary> /// <param name="contact">The value for the 'contact' parameter of this action.</param> /// <param name="callback">Callback to invoke when the operation completes.</param> /// <param name="userState">Value to pass to the callback. It can be <c>null</c>.</param> /// <returns>An operation instance that can be used to manage the asynchronous request.</returns> public InvokeOperation<Contact> ImportContact(Contact contact, Action<InvokeOperation<Contact>> callback, object userState) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("contact", contact); this.ValidateMethod("ImportContact", parameters); return ((InvokeOperation<Contact>)(this.InvokeOperation("ImportContact", typeof(Contact), parameters, true, callback, userState))); }
public static int Add(Contact contact) { contact.Id = NextId++; AllContacts.Add(contact); return contact.Id; }