Exemple #1
0
        // GET: NotificacionController/Edit/5
        public async Task <ActionResult> Edit(int id)
        {
            INotificacionService servicioNotificaciones = ObtenerServicio();
            NotificacionEntity   notificacionAsync      = await servicioNotificaciones.GetNotificacionAsync(id);

            return(View(notificacionAsync));
        }
        public async Task <NotificacionEntity> UpdateNotificacionAsync(NotificacionEntity notificacion)
        {
            var content      = JsonConvert.SerializeObject(notificacion);
            var httpResponse = await _client.PutAsync($"{BaseUrl}/{notificacion.Id}/", new StringContent(content, Encoding.Default, "application/json"));

            if (!httpResponse.IsSuccessStatusCode)
            {
                throw new Exception("Cannot update notificacion");
            }

            var notificacionCreado = JsonConvert.DeserializeObject <NotificacionEntity>(await httpResponse.Content.ReadAsStringAsync());

            return(notificacionCreado);
        }
Exemple #3
0
        public async Task <ActionResult> Edit(int id, IFormCollection collection)
        {
            try
            {
                INotificacionService servicioNotificaciones = ObtenerServicio();
                string             strAux = DateTime.Now.ToString();
                NotificacionEntity pe     = new NotificacionEntity()
                {
                    Id          = int.Parse(collection["Id"].ToString()),
                    Descripcion = collection["Descripcion"],
                    Fecha       = DateTime.Parse(collection["Fecha"].ToString()),
                    Tipo        = collection["Id"].ToString(),
                };

                NotificacionEntity pm = await servicioNotificaciones.UpdateNotificacionAsync(pe);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
 public void Put(int id, [FromBody] NotificacionEntity value)
 {
     listaNotificaciones.RemoveAll(n => n.Id == id);
     listaNotificaciones.Add(value);
 }
 public void Post([FromBody] NotificacionEntity value)
 {
     listaNotificaciones.Add(value);
 }