Esempio n. 1
0
        public async Task <ActionResult> Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var peripheral = await peripherialService.GetPeripheralByIdAsync(id);

            if (peripheral == null)
            {
                return(HttpNotFound());
            }

            var peripheralViewModel = mapper.Map <PeripheralViewModel>(peripheral);

            return(View(peripheralViewModel));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> GetPeripheralByIdAsync(long id)
        {
            try
            {
                var peripheral = await peripheralService.GetPeripheralByIdAsync(id);

                if (peripheral == null)
                {
                    return(new NotFoundError("PERIPHERAL NOT FOUND"));
                }

                return(Ok(peripheral));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }