public void UpdateContact(ContactsModel contact)
 {
     Kontakti contactData = _dataContext.Kontakts.Where(u => u.Id == contact.Id).SingleOrDefault();
     contactData.NorisesVieta = contact.Vieta;
     contactData.Adrese = contact.Adrese;
     contactData.PapildusInfo = contact.ExtraInfo;
     _dataContext.SubmitChanges();
 }
 public ContactsModel GetContactById(int contactId)
 {
     var query = from u in _dataContext.Kontakts
                 where u.Id == contactId
                 select u;
     var contact = query.FirstOrDefault();
     var model = new ContactsModel()
     {
         Id = contactId,
         Vieta = contact.NorisesVieta,
         Adrese = contact.Adrese,
         ExtraInfo = contact.PapildusInfo
     };
     return model;
 }
 public ActionResult Edit(ContactsModel contact)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _repository.UpdateContact(contact);
             return RedirectToAction("Index");
         }
     }
     catch (DataException)
     {
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return View(contact);
 }