Esempio n. 1
0
        public async Task <IHttpActionResult> PutDiarioGeneral(int id, DiarioGeneral diarioGeneral)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != diarioGeneral.DiarioGeneralID)
            {
                return(BadRequest());
            }

            db.Entry(diarioGeneral).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DiarioGeneralExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        private async void LoadDiarioGeneral()
        {
            this.IsRefreshing = true;
            //========================Validacion de la conexion al internet y el servidor===============================================================
            var connection = await this.apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                this.IsRefreshing = false;

                // "No se pudo conectar el servidor")
                if (connection.Result.ToString() == "No se pudo conectar el servidor")
                {
                    await Application.Current.MainPage.DisplayAlert(Languages.Error, Languages.NoServer, Languages.Accept);

                    System.Diagnostics.Process.GetCurrentProcess().CloseMainWindow();
                }
                else
                {
                    Device.BeginInvokeOnMainThread(async() =>
                                                   { await Application.Current.MainPage.DisplayAlert(Languages.Error, Languages.TurnOnInternet, Languages.Accept); });
                    CerrarPrograma();
                    return;
                }
            }
            //========================fin de la conexion al internet y el servidor======================================================================

            var url        = Application.Current.Resources["UrlAPI"].ToString();
            var prefix     = Application.Current.Resources["UrlPrefix"].ToString();
            var controller = Application.Current.Resources["UrlDiarioController"].ToString();
            //string id = $"{"/"}{App.IdActual}";

            var response = await this.apiService.GetList <DiarioGeneral>(url, prefix, controller);

            if (!response.IsSuccess)
            {
                this.IsRefreshing = false;
                await Application.Current.MainPage.DisplayAlert(Languages.Error, Languages.NoServer, Languages.Accept);

                return;
            }

            //this.MyClientes = (List<Clientes>)response.Result;

            //this.IsRefreshing = false;

            MainViewModel.GetInstance().DiarioGeneralList = (List <DiarioGeneral>)response.Result;
            this.DiarioGeneral = new ObservableCollection <DiarioGeneralItemViewModel>(this.ToDiarioItemViewModel());

            this.DebitoSum  = (decimal)DiarioGeneral.Sum(p => p.Debito);
            this.CreditoSum = (decimal)DiarioGeneral.Sum(p => p.Credito);

            CultureInfo cultureInfo = new CultureInfo("es-DO");

            this.Balance = string.Format(cultureInfo, "{0:C0}", this.CreditoSum - this.DebitoSum);

            this.IsRefreshing = false;
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> GetDiarioGeneral(int id)
        {
            DiarioGeneral diarioGeneral = await db.DiarioGenerals.FindAsync(id);

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

            return(Ok(diarioGeneral));
        }
Esempio n. 4
0
        public async Task <IHttpActionResult> PostDiarioGeneral(DiarioGeneral diarioGeneral)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DiarioGenerals.Add(diarioGeneral);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = diarioGeneral.DiarioGeneralID }, diarioGeneral));
        }
Esempio n. 5
0
        public async Task <IHttpActionResult> DeleteDiarioGeneral(int id)
        {
            DiarioGeneral diarioGeneral = await db.DiarioGenerals.FindAsync(id);

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

            db.DiarioGenerals.Remove(diarioGeneral);
            await db.SaveChangesAsync();

            return(Ok(diarioGeneral));
        }