Ejemplo n.º 1
0
        public async Task <IActionResult> Crear([FromBody] LugarCena item)
        {
            try
            {
                var r = await this.Repositorio.LugaresCena.AddAsync(item);

                await this.Repositorio.CompleteAsync();

                var db = await this.Repositorio.LugaresCena.GetLugarCenaConHotelByIdAsync(r.Id);

                db.Hotel.LugaresCena      = null;
                db.Hotel.LugaresCeremonia = null;
                db.Hotel.Agendas          = null;
                db.Hotel.BackUps          = null;
                db.Hotel.UsuariosHotel    = null;

                var obj = new
                {
                    ok        = true,
                    LugarCena = db
                };

                return(Ok(obj));
            }
            catch (Exception ex)
            {
                return(BadRequest(new
                {
                    ok = false,
                    mensaje = "Se produjo un error al crear el registro",
                    errors = new { mensaje = ex.Message }
                }));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Actualizar([FromBody] LugarCena itemNuevo, int id)
        {
            try
            {
                itemNuevo.Id = id;


                var itemEncontrado = await this.Repositorio.LugaresCena.GetByIdAsync(id);

                if (itemEncontrado == null)
                {
                    return(BadRequest(new { ok = false, mensaje = "No se encontró el registro a actulizar", erros = "" }));
                }

                itemEncontrado.Map(itemNuevo);

                var r = this.Repositorio.LugaresCena.Update(itemEncontrado);
                await this.Repositorio.CompleteAsync();

                var db = await this.Repositorio.LugaresCena.GetLugarCenaConHotelByIdAsync(r.Id);

                db.Hotel.LugaresCena      = null;
                db.Hotel.LugaresCeremonia = null;
                db.Hotel.Agendas          = null;
                db.Hotel.BackUps          = null;
                db.Hotel.UsuariosHotel    = null;


                var obj = new
                {
                    ok        = true,
                    LugarCena = db
                };

                return(Created("", obj));
            }
            catch (Exception ex)
            {
                return(BadRequest(new
                {
                    ok = false,
                    mensaje = "Se produjo un error al Actualizar el registro",
                    errors = new { mensaje = ex.Message }
                }));
            }
        }
Ejemplo n.º 3
0
        // CATALOGOS

        public static void Map(this LugarCena itemDb, LugarCena item)
        {
            itemDb.Lugar   = item.Lugar;
            itemDb.HotelId = item.HotelId;
            itemDb.Activo  = item.Activo;
        }