public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            var vm = new VisitHistoryViewModel();

            vm.VisitHistory = db.VisitHistories.Find(id);
            if (vm.VisitHistory == null)
            {
                return HttpNotFound();
            }

            vm.AttendingApplicationUsersSelectList = new SelectList(db.Users, "Id", "NameAndSurname");
            vm.SelectedAttendingApplicationUsers = vm.VisitHistory.AttendingApplicationUsers.Select(p => p.Id).ToList<string>();
            return View(vm);
        }
        public ActionResult Edit(VisitHistoryViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var item = db.Entry<VisitHistory>(vm.VisitHistory);
                item.State = System.Data.Entity.EntityState.Modified;
                item.Collection(i => i.AttendingApplicationUsers).Load();

                vm.VisitHistory.AttendingApplicationUsers.Clear();
                foreach (var saau in vm.SelectedAttendingApplicationUsers)
                {
                    var user = db.Users.Find(saau);
                    vm.VisitHistory.AttendingApplicationUsers.Add(user);
                }

                //item.Collection(i => i.Observation).Load();

                db.SaveChanges();
                return RedirectToAction("edit", "Caves", new { id = vm.VisitHistory.CaveId }).AddFragment("VisitHistorySection");
            }
            vm.AttendingApplicationUsersSelectList = new SelectList(db.Users, "Id", "UserName");
            return View(vm);
        }