public JsonResult SaveAndUnlock(UnlockRequest model) { if (ModelState.IsValid) { SecurityController security = new SecurityController(); Item item = Dbs.Db.GetItem(model.Id); if (item != null && security.IsUnlockable(item)) { if (model.RejectedFields != null && model.RejectedFields.Length > 0) { // revert changes } using (new EditContext(item)) item.Locking.Unlock(); return(Json(new { success = true, message = "ok" })); } else { return(Json(new { success = false, message = "invalid item" })); } } else { return(Json(new { success = false, message = "invalid request" })); } }
public ActionResult Modal(string Id) { SecurityController security = new SecurityController(); if (!string.IsNullOrEmpty(Id) && security.IsAuthorized()) { Item item = Dbs.Db.GetItem(Id); if (item != null && security.IsUnlockable(item)) { UnlockResponse response = new UnlockResponse(); response.Id = item.ID.ToString(); return(View("/~/Views/Modal.cshtml", response)); } } return(new EmptyResult()); }
public List <Notification> Get(Item item, bool checkDatasources = true) { SettingsController content = new SettingsController(); string command = content.GetCommand(); string commandDisplayName = content.GetCommandDisplayName(); string message; AccountController accounts = new AccountController(); SecurityController security = new SecurityController(); List <Notification> model = new List <Notification>(); List <Item> items = new List <Item>() { item }; if (checkDatasources) { items.AddRange(item.GetDataSources()); } if (items != null && items.Count > 0) { for (int i = 0; i < items.Count; i++) { if (security.IsUnlockable(items[i])) { Account owner = accounts.Get(items[i].Locking.GetOwner()); if (i == 0) { message = content.GetUnlockItemMessage(owner.Name, items[i].DisplayName); } else { message = content.GetUnlockDatasourceMessage(owner.Name, items[i].DisplayName); } model.Add(new Notification(items[i], owner, message, command, commandDisplayName)); } } } return(model); }