public async Task <IHttpActionResult> UpdateById(Contact contactUpdated)
        {
            var contact = await contactService.GetById(contactUpdated.Id);

            if (contact == null)
            {
                return(NotFound());
            }
            else
            {
                contactUpdated.Id = contact.Id;
                await contactService.Update(contactUpdated);

                return(Ok());
            }
        }
示例#2
0
 private void FormAddEditAndContact_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (DialogResult == DialogResult.OK)
     {
         if (string.IsNullOrEmpty(txtName.Text))
         {
             MessageBox.Show("Veuillez entrez le nom de votre contact !", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtName.Focus();
             e.Cancel = true;
             return;
         }
         if (IsNew)
         {
             ContactServices.Insert(contactBindingSource.Current as Contact);
         }
         else
         {
             ContactServices.Update(contactBindingSource.Current as Contact);
         }
     }
 }