public PartialViewResult Edit(int? id, List<int> userIds) { var model = new CircleEdit(); if (id != null) { var circle = _db.Circles.Include(c => c.Members).SingleOrDefault(c => c.CircleId == id); if (circle.UserId == CurrentUserId) { model.Name = circle.Name; model.Users = circle.Members; model.Id = circle.CircleId; } else { LogUnAuth(); throw new Exception(Strings.UnAuthAccess); } } else if(userIds != null) { model.Users = _db.Users.Where(u => userIds.Contains(u.UserId)).ToList(); } return PartialView("Edit", model); }
public JsonResult Update(CircleEdit model) { if (ModelState.IsValid) { try { if (model.Id == 0) { _srv.AddCircle(model.Name, model.AcSeleUserIds); } else { _srv.UpdateCircle(model.Id, model.Name, model.AcSeleUserIds); } } catch (SimpleException ex) { LogUnAuth(); AddModelError(ex); } } return GetErrorMsgJSON(); }