public static void Set(IItem item, PropertyDefinition propertyDefinition, RemindersState <T> newState) { Util.ThrowOnNullArgument(item, "item"); Util.ThrowOnNullArgument(propertyDefinition, "propertyDefinition"); Util.ThrowOnMismatchType <byte[]>(propertyDefinition, "propertyDefinition"); ExTraceGlobals.RemindersTracer.TraceDebug <StoreObjectId, PropertyDefinition>(0L, "RemindersState.Set - item={0}, propertyDefinition={1}", item.StoreObjectId, propertyDefinition); if (newState == null) { ExTraceGlobals.RemindersTracer.TraceDebug <PropertyDefinition>(0L, "RemindersState.Set - newState is null, deleting property={0}", propertyDefinition); item.Delete(propertyDefinition); return; } RemindersState <T> .ValidateStateIdentifiers(newState); ExTraceGlobals.RemindersTracer.TraceDebug <int>(0L, "RemindersState.Set - Serializing reminder states, count={0}", newState.StateList.Count); using (Stream stream = item.OpenPropertyStream(propertyDefinition, PropertyOpenMode.Create)) { if (newState.StateList.Count > 0) { IReminderState reminderState = newState.StateList[0]; newState.Version = reminderState.GetCurrentVersion(); } using (XmlWriter xmlWriter = XmlWriter.Create(stream)) { DataContractSerializer dataContractSerializer = new DataContractSerializer(typeof(RemindersState <T>)); dataContractSerializer.WriteObject(xmlWriter, newState); } } }
public async Task <ActionResult <ItemDTO> > DeleteItem(int id) { await _item.Delete(id); await _log.CreateLog(HttpContext, User.FindFirst("UserName").Value); return(NoContent()); }
public ActionResult Delete(int id) { var itemFromDb = _itemService.Get(id); if (itemFromDb == null) { return(NotFound()); } _itemService.Delete(itemFromDb); _itemService.SaveChanges(); return(NoContent()); }
public ActionResult RemoveItem(long id) { Func <ExtResult> removeFun = () => { dalItem.Delete(id); var ret = new ExtResult(); ret.success = true; return(ret); }; return(base.Remove(removeFun)); }
public IActionResult Delete(string id) { var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var item = _itemService.GetItem(id, userId); if (item == null) { return(NotFound()); } _itemService.Delete(item.Id, userId); return(NoContent()); }
public RedirectToActionResult Delete(int id) { if (!_session.ChkSession()) { return(RedirectToAction("Login", "Auth")); } var obj = _item.GetItem(id); if (obj == null || !_item.Delete(obj)) { return(RedirectToAction("List", new { msg = "Ошибка (объект не найден)" })); } return(RedirectToAction("List")); }
public void MenuItem() { int Choice; Console.WriteLine("====================================="); Console.WriteLine("======= MENU ITEM ======"); Console.WriteLine("====================================="); Console.WriteLine("|| 1. View All Data ||"); Console.WriteLine("|| 2. Insert ||"); Console.WriteLine("|| 3. Update ||"); Console.WriteLine("|| 4 Delete ||"); Console.WriteLine("======================================"); Console.Write("Pilihan....."); Choice = Convert.ToInt16(Console.ReadLine()); switch (Choice) { case 1: iItem.get(); Console.Read(); break; case 2: iItem.insert(item); Console.Read(); break; case 3: iItem.Update(Id, item); Console.Read(); break; case 4: iItem.Delete(Id); Console.Read(); break; default: Console.WriteLine("Exiting......"); Console.Read(); break; } Console.Read(); }
public IHttpActionResult Delete(int id) { try { var item = _repository.GetByID(id); if (item == null) { return(NotFound()); } _repository.Delete(id); return(Ok()); } catch (System.Exception ex) { return(BadRequest(ex.Message)); } }
public ItemBO Delete(string id) { return(_item.Delete(id)); }
public async Task <IActionResult> DeleteConfirmed(int id) { await _item.Delete(id); return(RedirectToAction(nameof(Index))); }
public void TestCreate() { string testFolderName = "porttest"; if (Session.ExistsPath("/", testFolderName)) { ICmisObject obj = Session.GetObjectByPath("/", testFolderName, OperationContextUtils.CreateMinimumOperationContext()); if (obj is IFolder) { ((IFolder)obj).DeleteTree(true, UnfileObject.Delete, true); } else { obj.Delete(); } } // create folder IFolder root = Session.GetRootFolder(); IFolder newFolder = CreateFolder(root, testFolderName); Assert.IsNotNull(newFolder); // create document string contentString = "Hello World"; IDocument newDoc = CreateTextDocument(newFolder, "test.txt", contentString); Assert.IsNotNull(newDoc); // get content IContentStream newContent = newDoc.GetContentStream(); Assert.IsNotNull(newContent); Assert.IsNotNull(newContent.Stream); Assert.AreEqual(contentString, ConvertStreamToString(newContent.Stream)); // fetch it again to get the updated content stream length property IOperationContext ctxt = OperationContextUtils.CreateMaximumOperationContext(); ICmisObject newObj = Session.GetObject(newDoc, ctxt); Assert.IsTrue(newObj is IDocument); IDocument newDoc2 = (IDocument)newObj; Assert.AreEqual(newDoc.Name, newDoc2.Name); Assert.AreEqual(Encoding.UTF8.GetBytes(contentString).Length, newDoc2.ContentStreamLength); // fetch it again newObj = Session.GetLatestDocumentVersion(newDoc, ctxt); Assert.IsTrue(newObj is IDocument); IDocument newDoc3 = (IDocument)newObj; Assert.AreEqual(newDoc.Id, newDoc3.Id); Assert.AreEqual(newDoc.Name, newDoc3.Name); // delete document newDoc.Delete(); try { Session.GetObject(newDoc); Assert.Fail("Document still exists."); } catch (CmisObjectNotFoundException) { // expected } Assert.IsFalse(Session.Exists(newDoc.Id)); // try an item IList <IObjectType> types = Session.GetTypeChildren(null, false).ToList(); Assert.IsNotNull(types); Assert.IsTrue(types.Count >= 2); if (types.Any(type => type.Id == "cmis:item")) { IItem newItem = CreateItem(newFolder, "testItem"); newItem.Delete(); Assert.IsFalse(Session.Exists(newItem.Id)); } // delete folder Assert.IsTrue(Session.ExistsPath(newFolder.Path)); newFolder.Delete(); Assert.IsFalse(Session.Exists(newFolder)); }
public IHttpActionResult AlteraStatus(int id, bool aprovado) { try { var os = _repository.GetByID(id); if (os == null) { return(NotFound()); } if (aprovado) { os.Status = Enums.StatusOrdemServico.APROVADO; if (os.OrdemServicoMotivo.AcaoFinal == Enums.AcaoFinalOrdemServico.EXCLUIR_ITEM) { var osItens = _itemRepository.GetByOrdemServicoID(os.ID); foreach (var item in osItens) { _itRepository.Delete(item.ItemID); } } if (os.OrdemServicoMotivo.AcaoFinal == Enums.AcaoFinalOrdemServico.ATUALIZAR_LOCAL_DESTINO) { var osMotivoID = os.OrdemServicoMotivoID; var osCampoLocalDestinoID = _campoRepository.GetByName("LocalDestinoID").ID; var osMotivoCampoLocalDestinoID = _motivoCampoRepository.GetByMotivoCampo(osMotivoID, osCampoLocalDestinoID).ID; var osMotivoCampoValorLocalDestino = Convert.ToInt32(_valorRepository.Get(os.ID, osMotivoCampoLocalDestinoID).Valor); var osItens = _itemRepository.GetByOrdemServicoID(os.ID); foreach (var osItem in osItens) { var item = osItem.Item; item.LocalID = osMotivoCampoValorLocalDestino; _itRepository.Update(item, true); } } } else { os.Status = Enums.StatusOrdemServico.REPROVADO; } _repository.Update(os); return(Ok(os)); } catch (System.Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IActionResult> UpdateCell() { try { string requestGuid = Common.GetGuidFromURL(Request.Path.ToString()); //Get guid from query string Guid libraryGuid = (requestGuid == null) ? Guid.Empty : (requestGuid == "") ? Guid.Empty : Guid.Parse(requestGuid); if (HttpContext.Request.Form["action"].ToString() == "create") //insert { Item item = new Item(); item.LibraryGuid = libraryGuid; item.Deleted = 0; await _iItem.Add(item); List <DataTableValidateMessage> validate = new List <DataTableValidateMessage>(); List <FieldValue> newRecord = new List <FieldValue>(); foreach (var key in HttpContext.Request.Form.Keys) { if (key != "action") { string fieldName = key.Replace("data[0][", "").Replace("]", ""); string keyValue = HttpContext.Request.Form[key].ToString(); var fieldValue = await _iField.FindByNameAndLibraryGuid(fieldName, libraryGuid); FieldValue value = new FieldValue(); //value.Field = fieldValue; value.LibraryGuid = libraryGuid; var validation = ValidateForm(fieldValue, HttpContext.Request.Form[key].ToString()); if (validation.Status == null) { if (validate.Count == 0) { value.Item = item; value.Value = keyValue; value.ItemGuid = item.GUID; value.Created = DateTime.Now; value.FieldID = fieldValue.ID; newRecord.Add(value); //await _iFieldValue.Add(value); } } else { validate.Add(validation); } } } if (validate.Count > 0) { return(new JsonResult(new { fieldErrors = validate })); } else { foreach (var newValue in newRecord) { await _iFieldValue.Add(newValue); } return(new JsonResult(new { result = "New record has been updated." })); } } else if (HttpContext.Request.Form["action"].ToString() == "edit")//cell update { foreach (var key in HttpContext.Request.Form.Keys) { if (key != "action") { string[] keys = Common.getUpdateKey(key); int itemID = Convert.ToInt32(keys[0].ToString()); var item = await _iItem.FindByID(itemID); var filedName = keys[1].ToString(); var fieldValue = await _iFieldValue.FindbyNameAndLibraryGuidAndItemID(filedName, libraryGuid, itemID); if (fieldValue == null) //propably new field just added to to the library, no field record has been added yet. Add new field to library record { var newField = await _iField.FindByNameAndLibraryGuid(filedName, libraryGuid); fieldValue = new FieldValue(); //fieldValue.Field = newField; fieldValue.Value = HttpContext.Request.Form[key].ToString(); var validation = ValidateForm(newField, HttpContext.Request.Form[key].ToString()); if (validation.Status == null) { fieldValue.Item = item; fieldValue.FieldID = newField.ID; fieldValue.ItemGuid = item.GUID; fieldValue.LibraryGuid = libraryGuid; fieldValue.Updated = DateTime.Now; await _iFieldValue.Add(fieldValue); } else { return(new JsonResult(new { status = false, result = validation.Status })); } } else { var validation = ValidateForm(fieldValue.Field, HttpContext.Request.Form[key].ToString()); if (validation.Status == null) { fieldValue.Value = HttpContext.Request.Form[key].ToString(); fieldValue.Updated = DateTime.Now; await _iFieldValue.Update(fieldValue); } else { return(new JsonResult(new { status = false, result = validation.Status })); } } return(new JsonResult(new { status = true, value = HttpContext.Request.Form[key].ToString(), result = filedName + " value " + fieldValue.Value + " has been updated" })); } } } else if (HttpContext.Request.Form["action"].ToString() == "remove")//remove) { string[] keys = Common.getUpdateKey(HttpContext.Request.Form.Keys.ToArray()[0]); await _iItem.Delete(Convert.ToInt32(keys[0])); return(new JsonResult(new { result = "Record has been deleted" })); } return(new JsonResult(new { result = "success" })); } catch (Exception ex) { return(new JsonResult(new { result = ex.Message })); } }
public void Delete(Item objItem) { Itemobj1.Delete(objItem); }