public async Task <IActionResult> PostMany([FromBody] ExhibitVisitedActionsArgs args)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var argList = args.ToListActionArgs();
            var validationResultList = new List <(int, ArgsValidationResult)>();

            foreach (var arg in argList)
            {
                validationResultList.Add((arg.EntityId, await ValidateActionArgs((ExhibitVisitedActionArgs)arg)));
                if (!validationResultList.Last().Item2.Success)
                {
                    continue;
                }

                var id = _entityIndex.NextId(ResourceTypes.Action);
                await EntityManager.CreateEntityAsync(_eventStore, (ExhibitVisitedActionArgs)arg, ResourceType, id, User.Identity.GetUserIdentity());
            }
            if (validationResultList.Any(x => x.Item2.Success))
            {
                return(StatusCode(201, String.Join(',', validationResultList.FindAll(x => x.Item2.Success)
                                                   .Select(x => x.Item1)
                                                   .ToArray())));
            }
            else
            {
                return(StatusCode(400, String.Join(',', validationResultList.Select(x => x.Item1).ToArray())));
            }
        }
Ejemplo n.º 2
0
        public static List <Action> Factory(ExhibitVisitedActionsArgs args)
        {
            var result = new List <Action>();

            foreach (var actionArg in args.ToListActionArgs())
            {
                result.Add(new ExhibitVisitedAction((ExhibitVisitedActionArgs)actionArg));
            }
            return(result);
        }