public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] Operation operation) { if (id != operation.ID) { return(NotFound()); } if (ModelState.IsValid) { await NetworkMethodModel.Put <Operation>(ConsulUri, id, operation); return(RedirectToAction(nameof(Index))); } return(View(operation)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Field")] ChangeField changeField) { if (id != changeField.ID) { return(NotFound()); } if (ModelState.IsValid) { await NetworkMethodModel.Put <ChangeField>(ConsulUri, id, changeField); return(RedirectToAction(nameof(Index))); } return(View(changeField)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] ViewCategory viewCategory) { if (id != viewCategory.ID) { return(NotFound()); } if (ModelState.IsValid) { await NetworkMethodModel.Put <ViewCategory>(ConsulUri, id, viewCategory); return(RedirectToAction(nameof(Index))); } return(View(viewCategory)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] CategoryType categoryType) { if (id != categoryType.ID) { return(NotFound()); } if (ModelState.IsValid) { await NetworkMethodModel.Put <CategoryType>(ConsulUri, id, categoryType); return(RedirectToAction(nameof(Index))); } return(View(categoryType)); }
public async Task <IActionResult> PostEdit() { var scenario = await NetworkMethodModel.Get <Scenerio>(_consulWrapper["track-api"]["Scenerios"], int.Parse(Request.Query["id"])); scenario.Json = Request.Query["json"]; scenario.ID = int.Parse(Request.Query["id"]); scenario.CategoryID = int.Parse(Request.Query["category"]); scenario.TypeID = int.Parse(Request.Query["categorytype"]); scenario.Name = Request.Query["name"]; scenario.ViewCategoryID = int.Parse(Request.Query["categoryView"]); var tracks = (await NetworkMethodModel.GetAll <Track>(_consulWrapper["track-api"]["Tracks"])) .Where(x => scenario.ScenerioTasks.Any(y => y.Track.ID == x.ID)); foreach (var t in tracks) { await NetworkMethodModel.Delete(_consulWrapper["track-api"]["Tracks"], t.ID); } scenario.ScenerioTasks = new List <ScenerioTask>(); 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.Put(_consulWrapper["track-api"]["Scenerios"], scenario.ID, scenario); return(Redirect("Index")); }