Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        public IHttpActionResult GetDocumentNumberDefinition(int id)
        {
            DocumentNumberDefinition documentNumberDefinition = db.DocumentNumberDefinitions.Find(id);

            if (documentNumberDefinition == null)
            {
                return(NotFound());
            }

            return(Ok(documentNumberDefinition));
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
        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;
            }
        }
Esempio n. 7
0
        protected override void OnEditCommand()
        {
            DocumentNumberDefinition documentNumberDefinition = DocumentNumberDefinitions[SelectedIndex];

            WindowHandler.WindowHandlerInstance.ShowWindow(documentNumberDefinition.Id, ActionType.Edit, typeof(DocumentNumberDefinitionForm), UnityContainer, this.GetType().Name);
        }