private static bool AddLanguage(TSUILanguage lang, List <string> CallTrace)
        {
            CosmosDocUILanguage UILanguage = CosmosAPI.cosmosDBClientUILanguage.FindByName(lang.Name, TodosCosmos.LocalFunctions.AddThisCaller(CallTrace, MethodBase.GetCurrentMethod())).Result;

            if (UILanguage is null)
            {
                return(CosmosAPI.cosmosDBClientUILanguage.Add(lang, TodosCosmos.LocalFunctions.AddThisCaller(CallTrace, MethodBase.GetCurrentMethod())).Result);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public async Task <ActionResult> Add(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "uilanguage/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()));

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



            CosmosDocUILanguage l = await CosmosAPI.cosmosDBClientUILanguage.FindByName(tsUILanguage.Name, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));


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

                if (b)
                {
                    return(new OkObjectResult("OK"));
                }
                else
                {
                    return(new OkObjectResult("Error:Can't add new UILanguage!"));
                }
            }
            else
            {
                return(new OkObjectResult("Error:UILanguage with name - " + tsUILanguage.Name + " exists already!"));
            }
        }
 public async Task <bool> Update(CosmosDocUILanguage tsUILanguage, List <string> CallTrace)
 {
     return(await cosmosDBClientBase.UpdateItemAsync(tsUILanguage, LocalFunctions.AddThisCaller(CallTrace, MethodBase.GetCurrentMethod())));
 }