public ActionResult <DeveloperReadDto> GetDeveloperById(Guid developerId) { var developerItem = _repository.GetDeveloperById(developerId); if (developerItem == null) { return(NotFound()); } return(Ok(_mapper.Map <DeveloperReadDto>(developerItem))); }
public void HandleDelete(int id) { var developer = developerRepository.GetDeveloperById(id); entityRepository.DeleteOnSave(developer); entityRepository.SaveChanges(); }
public VideogameValidatorResult Validate(VideogameForm form) { var errors = new List <string>(); if (string.IsNullOrWhiteSpace(form.Name)) { errors.Add("Name should not be empty"); } else if (form.Name.Length < 5) { errors.Add("Name length must be more then 5 characters"); } else if (form.Name.Length > 20) { errors.Add("Name length must be less then 20 characters"); } var developer = developerRepository.GetDeveloperById(form.DeveloperId); if (developer == null) { errors.Add($"Developer with id: [{form.DeveloperId}] not found"); } return(new VideogameValidatorResult { Errors = errors, isValid = errors.Count == 0 }); }
public DeveloperItemModel Build(int id) { var developer = developerRepository.GetDeveloperById(id); var item = new DeveloperItemModel { Id = developer.Id, Name = developer.Name }; return(item); }
public void HandleEdit(int id, DeveloperForm form) { var developer = developerRepository.GetDeveloperById(id); if (developer == null) { return; } entityRepository.AttachOnSave(developer); developer.Name = form.Name; entityRepository.SaveChanges(); }
public VideogameItemModel Build(int id) { var videogame = videogameRepository.GetIncludedById(id); var genreNames = videogame.Genres.Select(g => g.Name).ToList(); var developer = developerRepository.GetDeveloperById(videogame.DeveloperId); var devModel = new DeveloperItemModel { Id = developer.Id, Name = developer.Name, }; return(new VideogameItemModel(videogame.Id, videogame.Name, devModel, genreNames)); }