public async Task <IActionResult> Details(Guid id) { var phoneViewModel = _mapper.Map <PhoneViewModel>(await _phoneRepository.GetById(id)); if (phoneViewModel == null) { return(NotFound()); } return(View(phoneViewModel)); }
public async Task <IActionResult> DeletePhone(Guid id) { var phoneViewModel = _mapper.Map <PhoneViewModel>(await _phoneRepository.GetById(id)); if (phoneViewModel == null) { return(NotFound()); } return(PartialView("_DeletePhone", phoneViewModel)); }
public IActionResult Get(int id) { var phone = _phoneRepository.GetById(id); if (phone == null) { return(NotFound()); } return(Ok(phone)); }
// GET: Phones/Details/5 public IActionResult Details(int?id) { if (!id.HasValue) { return(NotFound()); } var phone = _phoneRepository.GetById(id.Value); if (phone == null) { return(NotFound()); } return(View(phone)); }
public async Task<Phone> Update(PhoneDto phoneDto) { Phone phone = await _phoneRepository.GetById(phoneDto.PhoneId); if (phone != null) { _mapper.Map(phoneDto, phone); phone.Validate(phone, new PhoneValidator()); _notifications.AddNotifications(phone.ValidationResult); if (!_notifications.HasNotifications) { await Put(phone); } } else { _notifications.AddNotification("404", "PhoneId", "Phone with id = " + phoneDto.PhoneId + " not found"); } return phone; }
public async Task <Phone> GetPhoneById(Guid id) { return(await _phoneRepository.GetById(id)); }
public Phone GetById(Guid id) { return(_repository.GetById(id)); }