public async Task <MainScreenResponse> UpdateScreen(ScreenRequest screenRequest)
 {
     try
     {
         var getScreen = _screenRepository.GetScreenById(screenRequest.ScreensId);
         if (getScreen.Result != null)
         {
             var Screen = _mapper.Map <Screens>(getScreen.Result);
             Screen.ScreensName = getScreen.Result.ScreensName;
             Screen.Description = getScreen.Result.Description;
             Screen.ModifiedOn  = DateTime.Now;
             Screen.ModifiedBy  = screenRequest.UserId.ToString();
             var dataScreen = await _screenRepository.UpdateAsync(Screen);
         }
         else
         {
             _response.Message = Constants.Screen_Not_Update;
             _response.Status  = false;
             return(_response);
         }
         _response.Message = Constants.Screen_Update_Success;
         _response.Status  = true;
         return(_response);
     }
     catch (Exception ex)
     {
         var msg = ex.Message;
         _response.Status  = false;
         _response.Message = Constants.DEFAULT_ERROR_MSG;
     }
     return(_response);
 }
        public ActionResult <Screen> Get(Guid id)
        {
            try
            {
                var screen = db.GetScreenById(id);
                if (screen == null)
                {
                    return(NotFound("The requested screen could not be found"));
                }

                return(Ok(screen));
            }
            catch (Exception ex)
            {
                return(InternalServerError($"Unable to process request.  Details: {ex.ToString()}"));
            }
        }
Example #3
0
        public async Task <IActionResult> Put(Guid screenId, IFormFile file)
        {
            try
            {
                var screen = screenDb.GetScreenById(screenId);
                if (screen == null)
                {
                    throw new NotFoundException("The specified screen ID does not exist");
                }

                var stream = file.OpenReadStream();
                await db.UpdateVideo(screenId, stream);
            }
            catch (NotFoundException nfex)
            {
                return(NotFound(nfex.Message));
            }
            catch (Exception ex)
            {
                return(InternalServerError($"Unable to process request.  Details: { ex.ToString() }"));
            }

            return(NoContent());
        }