Exemplo n.º 1
0
        public LicenseTypesResponse UpdateLicenseTypes(LicenseTypeUpdateRequest request, string UserId, string TenantId)
        {
            LicenseTypesResponse responseModel = new LicenseTypesResponse();

            LicenseTypesModel licenseTypesModel = GetLicenseTypeById(request, TenantId, out LicenseTypesStatusModel licenseTypesStatus);

            if (licenseTypesStatus.IsLicenseTypesFound)
            {
                licenseTypesModel.licenseTypeName = request.LicenseTypeName;
                licenseTypesModel.modifiedBy      = UserId;
                licenseTypesModel.modifiedDate    = DateTime.UtcNow;

                LicenseTypesModel result = _cosmosDBOperationsRepository.UpdateDocumentFromCollection(licenseTypesModel.id, licenseTypesModel, TenantId, licenseTypeCollectionId).Result;
                CommonFunctions.CopyProperties(result, responseModel);
            }
            return(responseModel);
        }
Exemplo n.º 2
0
        public LicenseTypesModel GetLicenseTypeById(LicenseTypeUpdateRequest request, string tenantId, out LicenseTypesStatusModel licenseTypesStatus)
        {
            if (!string.IsNullOrWhiteSpace(request.id))
            {
                request.id = request.id.ToLower();
            }

            licenseTypesStatus = new LicenseTypesStatusModel();
            string            query  = $" WHERE LOWER({licenseTypeCollectionId}.id) = '{request.id}'";
            LicenseTypesModel result = _cosmosDBOperationsRepository.GetItemByQueryFromCollectionAsync(
                query, tenantId, licenseTypeCollectionId).Result;

            if (result == null)
            {
                licenseTypesStatus.Message = String.Format($"License type '{request.LicenseTypeName}' not found");
                return(null);
            }

            licenseTypesStatus.IsLicenseTypesFound = true;
            return(result);
        }
        public IActionResult UpdateLicenseType([FromHeader(Name = "x-tenant")] string tenantid, [FromHeader(Name = "x-user")] string userId, [FromBody] LicenseTypeUpdateRequest requestModel)
        {
            ErrorModel           error         = null;
            LicenseTypesResponse responseModel = null;

            try
            {
                responseModel = _licenseTypeService.UpdateLicenseTypes(requestModel, userId, tenantid);
                if (!string.IsNullOrEmpty(responseModel.id))
                {
                    return(Ok(responseModel));
                }
                else
                {
                    return(StatusCode((int)HttpStatusCode.BadRequest, requestModel));
                }
            }
            catch (Exception ex)
            {
                //error = ExceptionHandler.GetErrorDetails(ex);
                Log.Error($"Search tasks request. {ex.ToString()}.");
                return(StatusCode(error.Status, requestModel));
            }
        }