public async Task <bool> UpdatePlt(int id, Platos entity) { try { var platos = await getById(id); var dto = new PlatosDTO { Id = entity.Id, Nombre = entity.Nombre, CantidadPersonas = entity.CantidadPersonas, Categoria = entity.Categoria, Ingredientes = entity.Ingredientes, Precio = entity.Precio }; var update = _mapper.Map(dto, platos); await Update(update); return(true); } catch (Exception) { return(false); } }
public async Task<ActionResult> Put(int id, PlatosDTO plato) { var platos = await _repository.GetById(id); if (platos == null) { return NotFound(); } if (ModelState.IsValid) { var response = await _repository.UpdatePlatoDto(id, plato); if (response) { return NoContent(); } else { return StatusCode(500); } } return BadRequest(); }
public async Task <bool> UpdatePlatoDto(int id, PlatosDTO entity) { try { var plato = await GetById(id); plato.Nombre = entity.Nombre; plato.Precio = entity.Precio; plato.Limite = entity.Limite; plato.Categoria = entity.Categoria; await Update(plato); return(true); } catch (Exception e) { return(false); } }
public async Task <List <PlatosDTO> > GetAllDto() { var list = await getAll(); var dtoList = new List <PlatosDTO>(); foreach (var item in list) { var dto = new PlatosDTO { Id = item.Id, Nombre = item.Nombre, Precio = item.Precio, Categoria = item.Categoria, CantidadPersonas = item.CantidadPersonas, Ingredientes = item.Ingredientes }; dtoList.Add(dto); } return(dtoList); }