public IHttpActionResult PutDocumentNumberDefinition(int id, DocumentNumberDefinition documentNumberDefinition) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != documentNumberDefinition.Id) { return(BadRequest()); } db.Entry(documentNumberDefinition).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DocumentNumberDefinitionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetDocumentNumberDefinition(int id) { DocumentNumberDefinition documentNumberDefinition = db.DocumentNumberDefinitions.Find(id); if (documentNumberDefinition == null) { return(NotFound()); } return(Ok(documentNumberDefinition)); }
protected override void OnDeleteCommand() { DocumentNumberDefinition documentNumberDefinition = DocumentNumberDefinitions[SelectedIndex]; bool?result = WindowHandler.WindowHandlerInstance.ShowConfirm($"Do you want to delete {documentNumberDefinition.Name}?", this.GetType().Name, UnityContainer, "Document number definition"); if (result == true) { ApiClient.DeleteDocumentNumberDefinitionsAsync(documentNumberDefinition.Id).Wait(); } InitializeData(); }
public IHttpActionResult PostDocumentNumberDefinition(DocumentNumberDefinition documentNumberDefinition) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DocumentNumberDefinitions.Add(documentNumberDefinition); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = documentNumberDefinition.Id }, documentNumberDefinition)); }
public IHttpActionResult DeleteDocumentNumberDefinition(int id) { DocumentNumberDefinition documentNumberDefinition = db.DocumentNumberDefinitions.Find(id); if (documentNumberDefinition == null) { return(NotFound()); } db.DocumentNumberDefinitions.Remove(documentNumberDefinition); db.SaveChanges(); return(Ok(documentNumberDefinition)); }
protected override void Initialize(int?entityId, ActionType actionType, List <object> additionalData = null) { base.Initialize(entityId, actionType, additionalData); switch (actionType) { case ActionType.Add: Entity = new DocumentNumberDefinition(); break; case ActionType.Edit: var task = ApiClient.GetDocumentNumberDefinitionAsync(entityId.Value); task.Wait(); Entity = task.Result; break; } }
protected override void OnEditCommand() { DocumentNumberDefinition documentNumberDefinition = DocumentNumberDefinitions[SelectedIndex]; WindowHandler.WindowHandlerInstance.ShowWindow(documentNumberDefinition.Id, ActionType.Edit, typeof(DocumentNumberDefinitionForm), UnityContainer, this.GetType().Name); }