public IActionResult Put(int id, [FromBody] EKartonDto dto, [FromServices] UpdateEKartonValidator validator) { dto.Id = id; var eKarton = _context.EKarton.Find(id); if (eKarton == null) { return(NotFound()); } var result = validator.Validate(dto); if (!result.IsValid) { throw new Exception();// prepraviti sa klasom error/ medelja 5-subota termin } _mapper.Map(dto, eKarton); try { _context.SaveChanges(); return(NoContent()); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public void Execute(EKartonDto request) { _validator.ValidateAndThrow(request); var ekarton = new EKarton { Date = request.Date, Price = request.Price }; _context.EKarton.Add(ekarton); _context.SaveChanges(); }
public void Execute(EKartonDto request) { _validator.ValidateAndThrow(request); var eKarton = _context.EKarton.Find(request.Id); eKarton.Date = request.Date; eKarton.UserId = request.UserId; eKarton.JawJawSideToothId = request.JawJawSideToothId; eKarton.Price = request.Price; eKarton.ServiceTypeId = request.ServiceTypeId; _context.SaveChanges(); }
public void Post([FromBody] EKartonDto dto, [FromServices] ICreateEKartonCommand command, [FromServices] CreateEKartonValidator validator) { _executor.ExecuteCommand(command, dto); }