Пример #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));
 }