public ActionResult Edit(ServiceEditViewModel service) { if (ModelState.IsValid) { _serviceManager.Update(service); } return RedirectToAction("Index"); }
public void Update(ServiceEditViewModel updatedObject) { if (updatedObject.SelectedTags != null && updatedObject.SelectedTags.Count() != 0) { var res = _tagRepository.Find(p => updatedObject.SelectedTags.Cast<int>().Contains(p.PK_ID)); if (res.Any()) { foreach (var tag in res) { updatedObject.CurrentServiceObject.Tags.Add(tag); } } } _serviceRepository.Update(updatedObject.CurrentServiceObject); _serviceRepository.Save(); }
public ServiceEditViewModel Update(int updatedObjectPrimaryKey) { ServiceEditViewModel vm = new ServiceEditViewModel(); vm.CurrentServiceObject = _serviceRepository.GetById(updatedObjectPrimaryKey); vm.Users = _userRepository .All() .ToList() .Select(e => new SelectListItem { Text = e.Name, Value = e.PK_ID.ToString() }) .WithEmptyItem("Select developer") .WithSelection(vm.CurrentServiceObject.FK_Owner.ToString()) .ToList(); // getting tags IEnumerable<SRREntityTagKeywords> tags = _tagRepository.All().ToList(); vm.Tags = new MultiSelectList(tags, "PK_ID", "Name", vm.CurrentServiceObject.Tags.Select(p => p.PK_ID).ToArray()); return vm; }