public HttpResponseMessage IsUpdateAvailable(IsUpdateAvailableRequestModel requestModel)
        {

            requestModel = new IsUpdateAvailableRequestModel() {

                InstallationGuid = requestModel.InstallationGuid,
                LastDateModified = requestModel.LastDateModified

                //InstallationGuid = Guid.Parse("90b2044c-ae0a-46f3-9260-acf3a058294a"),
                //LastDateModified = DateTime.Now
            };


            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid Download Request");
            }

            UpdateActions updateActions = new UpdateActions();
            IsUpdateAvailableResponseModel responseModel = updateActions.IsUpdateAvailable(requestModel);

            if (responseModel.Error != null)
            {
                return Request.CreateErrorResponse(HttpStatusCode.OK, responseModel.Error);
            }

            return Request.CreateResponse(HttpStatusCode.OK, responseModel, "application/json");
        }
Esempio n. 2
0
        public IsUpdateAvailableResponseModel IsUpdateAvailable(IsUpdateAvailableRequestModel requestmodel)
        {
            IsUpdateAvailableResponseModel responseModel = new IsUpdateAvailableResponseModel();

            InstallationRepo installationrepo = new InstallationRepo();
            bool IsEnable = installationrepo.IsInstallationEnable(requestmodel.InstallationGuid);

            if(!IsEnable)
            {
                responseModel.IsValid = true;
                responseModel.IsInstallationValid = false;
                responseModel.IsUpdateAvailable = false;
                responseModel.Error = null;
                return responseModel;
            }

            UpdateRepo updaterepo = new UpdateRepo();
            EnumTypes.UpdateAvailable isChecker = updaterepo.checkForUpdate(requestmodel.InstallationGuid, requestmodel.LastDateModified);

            if(isChecker == EnumTypes.UpdateAvailable.UpdateNotAvailable)
            {
                responseModel.IsInstallationValid = true;
                responseModel.IsValid = true;
                responseModel.IsUpdateAvailable = false;
                responseModel.Error = null;
                return responseModel;
            }

            if(isChecker == EnumTypes.UpdateAvailable.UpdateAvailable)
            {
                responseModel.IsInstallationValid = true;
                responseModel.IsValid = true;
                responseModel.IsUpdateAvailable = true;
                responseModel.Error = null;
                return responseModel;
            }

            responseModel.IsInstallationValid = true;
            responseModel.IsValid = false;
            responseModel.IsUpdateAvailable = false;
            responseModel.Error = "Installation Not Exist";
            return responseModel;
        }
 public IsUpdateAvailableResponseModel IsUpdateAvailable(IsUpdateAvailableRequestModel requestModel)
 {
     UpdateCase updatecase = new UpdateCase();
     return updatecase.IsUpdateAvailable(requestModel);
 }