public async Task <IActionResult> Create([Bind("ID,Name")] Operation operation)
        {
            if (ModelState.IsValid)
            {
                await NetworkMethodModel.Post <Operation>(ConsulUri, operation);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(operation));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("ID,Name")] ViewCategory viewCategory)
        {
            if (ModelState.IsValid)
            {
                await NetworkMethodModel.Post <ViewCategory>(ConsulUri, viewCategory);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(viewCategory));
        }
        public async Task <IActionResult> Create([Bind("ID,Field")] ChangeField changeField)
        {
            if (ModelState.IsValid)
            {
                await NetworkMethodModel.Post <ChangeField>(ConsulUri, changeField);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(changeField));
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("ID,Name")] CategoryType categoryType)
        {
            if (ModelState.IsValid)
            {
                await NetworkMethodModel.Post <CategoryType>(ConsulUri, categoryType);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoryType));
        }
示例#5
0
        public async Task <IActionResult> Create([Bind("ID,Name,Date,Description")] Event @event)
        {
            if (ModelState.IsValid)
            {
                await NetworkMethodModel.Post <Event>(ConsulUri, @event);

                SendMessageToBus(@event, this.Login("qwer"));
                return(RedirectToAction(nameof(Index)));
            }
            return(View(@event));
        }
示例#6
0
        public async Task <IActionResult> PostCreate()
        {
            var scenario = new Scenerio
            {
                Json           = Request.Query["json"],
                CategoryID     = int.Parse(Request.Query["category"]),
                TypeID         = int.Parse(Request.Query["categorytype"]),
                Name           = Request.Query["name"],
                ScenerioTasks  = new List <ScenerioTask>(),
                ViewCategoryID = int.Parse(Request.Query["categoryView"])
            };

            var track = new Track {
            };

            scenario.ScenerioTasks.Add(new ScenerioTask {
                Scenerio = scenario, Track = track
            });

            var flows = Request.Query.Where(x => x.Key.Contains("usertype_")).Select(x => x.Key.Replace("usertype_", string.Empty));

            foreach (var flow in flows)
            {
                var action = new CommonLibrary.DatabaseModels.Action
                {
                    IsAuto          = Request.Query.ContainsKey($"auto_{flow}"),
                    ChangeFields    = new List <ChangeFieldInAction>(),
                    ValidateActions = new List <ValidateAction>(),
                    UserType        = (UserType)int.Parse(Request.Query[$"usertype_{flow}"]),
                    DaysCount       = int.Parse(Request.Query[$"day_{flow}"]),
                    State           = await NetworkMethodModel.Get <State>(_consulWrapper["track-api"]["States"], int.Parse(Request.Query[$"from_{flow}"])),
                    NextState       = await NetworkMethodModel.Get <State>(_consulWrapper["track-api"]["States"], int.Parse(Request.Query[$"to_{flow}"])),
                };
                track.ActionInTracks.Add(new ActionInTrack {
                    Action = action, Track = track
                });

                var groupFields = Request.Query.Where(x => x.Key.Contains($"select_{flow}")).ToList();
                foreach (var field in groupFields)
                {
                    action.ChangeFields.Add(new ChangeFieldInAction
                    {
                        Action      = action,
                        ChangeField = (await NetworkMethodModel.GetByName <ChangeField>(_consulWrapper["track-api"]["ChangeFields"], field.Value))
                    });
                }

                var groupValid = Request.Query.Where(x => x.Key.StartsWith(flow)).GroupBy(x => x.Key.Substring(x.Key.IndexOf("comp")));
                foreach (var validGroup in groupValid)
                {
                    action.ValidateActions.Add(new ValidateAction
                    {
                        Action        = action,
                        ValidateField = new ValidateField
                        {
                            Field     = validGroup.First().Value,
                            Operation = (await NetworkMethodModel.GetByName <Operation>(_consulWrapper["track-api"]["Operations"], validGroup.ElementAt(1).Value)),
                            With      = validGroup.Last().Value
                        }
                    });
                }
            }

            await NetworkMethodModel.Post(_consulWrapper["track-api"]["Scenerios"], scenario);

            return(Redirect("Index"));
        }