public static void updateMueble(Mueble muebleToUpdate)
 {
     try
     {
         if (muebleToUpdate.idMueble < 0 || string.IsNullOrEmpty(muebleToUpdate.nombre) || string.IsNullOrEmpty(muebleToUpdate.color) || string.IsNullOrEmpty(muebleToUpdate.precio.ToString()) ||
             string.IsNullOrEmpty(muebleToUpdate.cantidad_stock.ToString()))
         {
             throw new Exception("Introduzca todos los campos");
         }
         if (muebleToUpdate.nombre.Length < 4)
         {
             throw new Exception("La longitud de caracteres del nombre es muy corta");
         }
         if (muebleToUpdate.color.Length < 4)
         {
             throw new Exception("La longitud de caracteres del nombre es muy corta");
         }
         if (muebleToUpdate.precio < 0)
         {
             throw new Exception("El precio no puede ser negativo");
         }
         if (muebleToUpdate.cantidad_stock < 0)
         {
             throw new Exception("Cantidad de stock Invalida");
         }
         else
         {
             MuebleModel.updateMueble(muebleToUpdate);
         }
     }
     catch (Exception ex)
     {
         throw  ex;
     }
 }
예제 #2
0
        public async Task <IActionResult> Post(MuebleModel request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var mueble = await this._muebleService.PostMueble(request);

            return(Ok(mueble));
        }
 public static List <Mueble> searchMuebleByMultipleId(List <int> idMueble)
 {
     try
     {
         return(MuebleModel.searchMuebleByMultipleId(idMueble));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static Mueble searchMuebleById(int idMueble)
 {
     try
     {
         return(MuebleModel.searchMuebleById(idMueble));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static List <Mueble> searchMuebleByCriteria(string criteria)
 {
     try
     {
         return(MuebleModel.searchMuebleByCriteria(criteria));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static void removeMueble(int id_mueble_to_remove)
 {
     try
     {
         if (id_mueble_to_remove > 0)
         {
             MuebleModel.removeMueble(id_mueble_to_remove);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #7
0
        public async Task <MuebleEntity> PostMueble(MuebleModel model)
        {
            MuebleEntity mueble = new MuebleEntity
            {
                Marca  = model.Marca,
                Modelo = model.Modelo,
                Precio = model.Precio
            };

            this._dbContext.Set <MuebleEntity>().Add(mueble);

            await this._dbContext.SaveChangesAsync();

            return(mueble);
        }
예제 #8
0
 public async Task <MuebleEntity> PutMueble(MuebleModel model)
 {
     throw new NotImplementedException();
 }