예제 #1
0
        public async Task <IActionResult> Details(Guid id)
        {
            var phoneViewModel = _mapper.Map <PhoneViewModel>(await _phoneRepository.GetById(id));

            if (phoneViewModel == null)
            {
                return(NotFound());
            }

            return(View(phoneViewModel));
        }
예제 #2
0
        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));
        }
예제 #3
0
        public IActionResult Get(int id)
        {
            var phone = _phoneRepository.GetById(id);

            if (phone == null)
            {
                return(NotFound());
            }

            return(Ok(phone));
        }
예제 #4
0
        // 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));
        }
예제 #5
0
        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;
        }
예제 #6
0
 public async Task <Phone> GetPhoneById(Guid id)
 {
     return(await _phoneRepository.GetById(id));
 }
예제 #7
0
 public Phone GetById(Guid id)
 {
     return(_repository.GetById(id));
 }