public async Task <ActionResult <ServicioDTO> > Put(int id, [FromBody] ServicioCreateDTO servicioCreate) { var servicio = mapper.Map <Servicio>(servicioCreate); var servicioRepo = await repository.Update(id, servicio); if (servicioRepo == null) { return(NotFound()); } var servicioDTO = mapper.Map <ServicioDTO>(servicioRepo); return(new CreatedAtRouteResult("ObtenerServiciov1", new { id = servicio.Id }, servicioDTO)); }
public IActionResult OnPost(int id) { if (!ModelState.IsValid) { return(Page()); } var materiaToUpdate = _materiaRepository.GetByID(id); if (materiaToUpdate == null) { return(NotFound()); } materiaToUpdate.Codigo = Materia.Codigo; materiaToUpdate.Description = Materia.Description; materiaToUpdate.Habilitada = Materia.Habilitada; _materiaRepository.Update(Materia); return(RedirectToPage("./Materias")); }
public async Task <CommentResponse> CreateAsync(Comment comment) { try { _commentRepository.Add(comment); var servicio = await _servicioRepository.FindFirstByConditionAsync(s => s.ID == comment.ServicioID); if (servicio != null) { servicio.UpdateAverages(comment.RatingFood, comment.RatingService); _servicioRepository.Update(servicio); } await _unitOfWork.CompleteAsync(); return(new CommentResponse(comment)); } catch (Exception ex) { return(new CommentResponse($"There was an error creating the comment: {ex.Message}")); } }
public async Task <ServicioResponse> UpdateAsync(int id, Servicio servicio) { var existingServicio = await _servicioRepository.FindFirstByConditionAsync(u => u.ID == id); if (existingServicio == null) { return(new ServicioResponse("Servicio not found")); } existingServicio = servicio; try { _servicioRepository.Update(existingServicio); await _unitOfWork.CompleteAsync(); return(new ServicioResponse(existingServicio)); } catch (Exception ex) { return(new ServicioResponse($"An error occurred when updating the servicio: {ex.Message}")); } }
public bool Update(Servicio entity) { return(servicioRepository.Update(entity)); }