public IActionResult PatientEdited(EditedPatient patient)
 {
     if (ModelState.IsValid)
     {
         var client = new ResourceGetter();
         if (string.IsNullOrEmpty(patient.Id))
         {
             return(RedirectToAction("Patient", "Home"));
         }
         //fetch original patient
         var originalPatient = client.GetItem <Patient>(patient.Id);
         if (originalPatient != null)
         {
             if (patient.TryMergeWithResource(originalPatient))
             {
                 client.UpdateItem(originalPatient);
             }
         }
     }
     else
     {
         return(View("EditPatient", patient));
     }
     return(RedirectToAction("Patient", "Home"));
 }
 public IActionResult CreatePatient(EditedPatient patient)
 {
     if (ModelState.IsValid)
     {
         var client = new ResourceGetter();
         client.AddItem(patient.MapToResource());
         return(RedirectToAction("InfoIndex", "Home", new { infoMessage = $"Dodano rekord {patient.GivenName} {patient.FamilyName}." }));
     }
     else
     {
         return(View(patient));
     }
 }
        public IActionResult EditPatient(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Patient", "Home"));
            }
            var res     = new ResourceGetter();
            var patient = res.GetItem <Patient>(id);

            if (patient == null)
            {
                return(RedirectToAction("Patient", "Home"));
            }
            var editablePatient = new EditedPatient(id);

            editablePatient.MapFromResource(patient);
            return(View(editablePatient));
        }