Exemplo n.º 1
0
        /// <summary>
        /// Example Crud
        /// </summary>
        private async void ExampleCRUD()
        {
            var item = new Models.Catalogs.ProgressReportModel {
                Description = "insert exmaple"
            };

            // Insert Example
            var resultInsert = await RunSafeApi(progressReportService.Post(item));

            if (resultInsert.Status == TypeReponse.Ok)
            {
                if (resultInsert.Response > 0)
                {
                    item.ReportId = resultInsert.Response;
                    Debug.WriteLine("Success", TAG);
                }
                else
                {
                    Debug.WriteLine("Error insert", TAG);
                }
            }
            else
            {
                Debug.WriteLine("Error request", TAG);
            }
            // Update Exmaple
            item.Description = "Update Exmaple";
            var resultUpdate = await RunSafeApi(progressReportService.Put(item.ReportId, item));

            if (resultUpdate.Status == TypeReponse.Ok)
            {
                if (resultUpdate.Response >= 0)
                {
                    Debug.WriteLine("Success", TAG);
                }
                else
                {
                    Debug.WriteLine("Error update", TAG);
                }
            }
            else
            {
                Debug.WriteLine("Error request", TAG);
            }
            // ListSell Example
            var resultListSell = await RunSafeApi(progressReportService.ListaSelAll());

            if (resultListSell.Status == TypeReponse.Ok)
            {
                if (resultListSell.Response.ProgressReports != null && resultListSell.Response.RowCount > 0)
                {
                    Debug.WriteLine("Success", TAG);
                }
                else
                {
                    Debug.WriteLine("No items", TAG);
                }
            }
            else
            {
                Debug.WriteLine("Error request", TAG);
            }
            // Delete Example
            var resultDelete = await RunSafeApi(progressReportService.Delete(item.ReportId));

            if (resultDelete.Status == TypeReponse.Ok)
            {
                if (resultDelete.Response)
                {
                    Debug.WriteLine("Success", TAG);
                }
                else
                {
                    Debug.WriteLine("Error delete", TAG);
                }
            }
            else
            {
                Debug.WriteLine("Error request", TAG);
            }
        }
Exemplo n.º 2
0
 public Task <int> Post([Body] ProgressReportModel item)
 {
     return(services.Post(item));
 }