private static bool AddUIWordNative(string word, List <string> CallTrace)
        {
            if (!string.IsNullOrEmpty(word))
            {
                word = word.ToLower();
                CosmosDocUIWordNative UIWordNative = CosmosAPI.cosmosDBClientUIWordNative.FindByWord(word, TodosCosmos.LocalFunctions.AddThisCaller(CallTrace, MethodBase.GetCurrentMethod())).Result;

                if (UIWordNative is null)
                {
                    TSUIWordNative uiWordNative = new TSUIWordNative()
                    {
                        ID   = Guid.NewGuid(),
                        Word = word
                    };

                    return(CosmosAPI.cosmosDBClientUIWordNative.Add(uiWordNative, TodosCosmos.LocalFunctions.AddThisCaller(CallTrace, MethodBase.GetCurrentMethod())).Result);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public async Task <ActionResult> Add(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "uiwordnative/add")] HttpRequest req,
            ILogger log)
        {
            List <WebApiUserTypesEnum> localAllowedRoles = new List <WebApiUserTypesEnum>
            {
                WebApiUserTypesEnum.Admin
            };

            ClaimsPrincipal User = MyTokenValidator.Authenticate(req, localAllowedRoles, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));

            TSUIWordNative tsUIWordNative = await MyFromBody <TSUIWordNative> .FromBody(req, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));



            CosmosDocUIWordNative l = await CosmosAPI.cosmosDBClientUIWordNative.FindByWord(tsUIWordNative.Word, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));


            if (l is null)
            {
                bool b = await CosmosAPI.cosmosDBClientUIWordNative.Add(tsUIWordNative, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));

                if (b)
                {
                    return(new OkObjectResult("OK"));
                }
                else
                {
                    return(new OkObjectResult("Error:Can't add new UIWordNative!"));
                }
            }
            else
            {
                return(new OkObjectResult("Error:UIWordNative with word - " + tsUIWordNative.Word + " exists already!"));
            }
        }
 public async Task <bool> UpdateEntity(CosmosDocUIWordNative tsUIWordNative, List <string> CallTrace)
 {
     return(await cosmosDBClientBase.UpdateItemAsync(tsUIWordNative, LocalFunctions.AddThisCaller(CallTrace, MethodBase.GetCurrentMethod())));
 }