public static async Task <ActionResultWithId> HttpProcessing <DbElement, InputElement>(HttpRequest req, ILogger log, string ObjectIdAAD, Func <IAgroManager <GeographyPoint>, IGenericOperation <DbElement, InputElement> > repo, InputElement element) where DbElement : DocumentBase where InputElement : InputBase
        {
            var method = req.Method.ToLower();

            switch (method)
            {
            case "get":
                if (!string.IsNullOrWhiteSpace(element.Id))
                {
                    var manager = await ContainerMethods.AgroManager(ObjectIdAAD);

                    var elementDb = await repo(manager).Get(element.Id);

                    return(new ActionResultWithId {
                        Id = element.Id,
                        JsonResult = ContainerMethods.GetJsonGetContainer(elementDb, log)
                    });
                }
                return(new ActionResultWithId {
                    Id = null,
                    JsonResult = ContainerMethods.GetJsonGetContainer(new ExtGetContainer <string> {
                        ErrorMessage = "Id obligatorio", StatusResult = ExtGetDataResult.Error
                    }, log)
                });

            default:

                string EntityName = ((DbElement)Activator.CreateInstance(typeof(DbElement))).CosmosEntityName;

                var opInstance = new OperationInstance <InputElement>(element, element.Id, EntityName, method, ObjectIdAAD);


                try
                {
                    await ServiceBus.PushElement(opInstance, EntityName);
                }
                catch (Exception e)
                {
                    Console.WriteLine("error en el service bus");
                }

                return(new ActionResultWithId {
                    Id = null,
                    JsonResult = new JsonResult("Operacion en cola.")
                });
            }
        }
        public static async Task <ActionResultWithId> HttpProcessing <DbElement, InputElement>(HttpRequest req, ILogger log, string ObjectIdAAD, Func <IAgroManager, IGenericOperation <DbElement, InputElement> > repo, InputElement element) where DbElement : DocumentBase where InputElement : InputBase
        {
            var method = req.Method.ToLower();

            switch (method)
            {
            case "get":
                if (!string.IsNullOrWhiteSpace(element.Id))
                {
                    var manager = await ContainerMethods.AgroManager(ObjectIdAAD, false);

                    var elementDb = await repo(manager).Get(element.Id);

                    return(new ActionResultWithId {
                        Id = element.Id,
                        JsonResult = ContainerMethods.GetJsonGetContainer(elementDb, log)
                    });
                }
                return(new ActionResultWithId {
                    Id = null,
                    JsonResult = ContainerMethods.GetJsonGetContainer(new ExtGetContainer <string> {
                        ErrorMessage = "Id obligatorio", StatusResult = ExtGetDataResult.Error
                    }, log)
                });

            default:
                //ExtPostContainer<string> saveReturn;
                string EntityName = ((DbElement)Activator.CreateInstance(typeof(DbElement))).CosmosEntityName;
                var    opInstance = new OperationInstance <InputElement>(element, element.Id, EntityName, method, ObjectIdAAD);
                await ServiceBus.PushElement(opInstance, EntityName);

                return(new ActionResultWithId {
                    Id = null,
                    JsonResult = new JsonResult("Operacion en cola.")
                });
                //try {
                //    saveReturn = await repo.SaveInput(element, false);
                //    await recordAcitvity.SaveInput(new UserActivityInput {
                //        Action = method.Equals("post") ? UserActivityAction.CREATE : UserActivityAction.MODIFY,
                //        Date = DateTime.Now,
                //        EntityName = ((DbElement)Activator.CreateInstance(typeof(DbElement))).CosmosEntityName,
                //        EntityId = saveReturn.IdRelated
                //    }, false);
                //}
                //catch (Exception ex) {
                //    var extPostError = new ExtPostErrorContainer<string> {
                //        InternalException = ex,
                //        Message = ex.Message,
                //        MessageResult = ExtMessageResult.Error
                //    };
                //    if (ex is Validation_Exception)
                //        extPostError.ValidationMessages = ((Validation_Exception)ex).ErrorMessages;
                //    return new ActionResultWithId {
                //        Id = null,
                //        JsonResult = ContainerMethods.GetJsonPostContainer(extPostError, log)
                //    };
                //}
                //return new ActionResultWithId {
                //    Id = saveReturn.IdRelated,
                //    JsonResult = ContainerMethods.GetJsonPostContainer(saveReturn, log)
                //};
            }
        }