private BootstrapData SaveBootstrapData(BootstrapData vm) { var isUpdate = vm.Id > 0; var bootstrapData = new BootstrapData(); var processedOrderChanged = false; if (isUpdate) { bootstrapData = dataFlowDbContext.BootstrapData.FirstOrDefault(x => x.Id == vm.Id); bootstrapData.Id = vm.Id; processedOrderChanged = bootstrapData.ProcessingOrder != vm.ProcessingOrder; } bootstrapData.EntityId = vm.EntityId; bootstrapData.Data = vm.Data; bootstrapData.ProcessingOrder = vm.ProcessingOrder; bootstrapData.ProcessedDate = isUpdate ? vm.ProcessedDate : null; bootstrapData.CreateDate = isUpdate ? vm.CreateDate : DateTime.Now; bootstrapData.UpdateDate = DateTime.Now; dataFlowDbContext.BootstrapData.AddOrUpdate(bootstrapData); dataFlowDbContext.SaveChanges(); LogService.Info(LogTemplates.InfoCrud("BootstrapData", bootstrapData.EntityId.ToString(), bootstrapData.Id, LogTemplates.EntityAction.Added)); ReorderBootstrapData(bootstrapData.ProcessingOrder, bootstrapData.Id, false, isUpdate && processedOrderChanged); return(bootstrapData); }
public async Task <ActionResult> Delete(int id) { var lookup = dataFlowDbContext.Lookups.FirstOrDefault(x => x.Id == id); if (lookup != null) { LogService.Info(LogTemplates.InfoCrud("Lookup", lookup.Key, lookup.Id, LogTemplates.EntityAction.Deleted)); dataFlowDbContext.Lookups.Remove(lookup); await dataFlowDbContext.SaveChangesAsync(); } return(RedirectToAction("Index")); }
public ActionResult Edit(DataMap vm) { if (!ModelState.IsValid) { ViewBag.Entities = new SelectList(GetEntityList, "Value", "Text"); return(View(vm)); } SaveDataMap(vm); LogService.Info(LogTemplates.InfoCrud("DataMap", vm.Name, vm.Id, LogTemplates.EntityAction.Deleted)); return(RedirectToAction("Index")); }
public async Task <ActionResult> Delete(int id) { var agent = dataFlowDbContext.Agents.FirstOrDefault(x => x.Id == id); if (agent != null) { LogService.Info(LogTemplates.InfoCrud("Agent", agent.Name, agent.Id, LogTemplates.EntityAction.Deleted)); dataFlowDbContext.Agents.Remove(agent); await dataFlowDbContext.SaveChangesAsync(); } return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { var bootstrapData = dataFlowDbContext.BootstrapData.FirstOrDefault(x => x.Id == id); if (bootstrapData != null) { LogService.Info(LogTemplates.InfoCrud("BootstrapData", bootstrapData.EntityId.ToString(), bootstrapData.Id, LogTemplates.EntityAction.Deleted)); var startFrom = bootstrapData.ProcessingOrder; dataFlowDbContext.BootstrapData.Remove(bootstrapData); dataFlowDbContext.SaveChanges(); ReorderBootstrapData(startFrom, 0, true, false); } return(RedirectToAction("Index")); }
public ActionResult Edit(SchoolViewModel.AddOrUpdate vm) { if (!GetSelectedGradeLevels(vm).Any()) { ModelState.AddModelError("NoGradesSelected", "Please select the grade levels for this school."); } if (!ModelState.IsValid) { ViewBag.Districts = new SelectList(GetDistrictList, "Value", "Text"); return(View(vm)); } SaveSchool(vm); LogService.Info(LogTemplates.InfoCrud("School", vm.School.NameOfInstitution, vm.School.SchoolId, LogTemplates.EntityAction.Modified)); return(RedirectToAction("Index")); }
private DataFlow.Models.Lookup SaveLookup(DataFlow.Models.Lookup vm) { var isUpdate = vm.Id > 0; var lookup = new DataFlow.Models.Lookup(); if (isUpdate) { lookup = dataFlowDbContext.Lookups.FirstOrDefault(x => x.Id == vm.Id); lookup.Id = vm.Id; } lookup.GroupSet = vm.GroupSet; lookup.Key = vm.Key; lookup.Value = vm.Value; dataFlowDbContext.Lookups.AddOrUpdate(lookup); dataFlowDbContext.SaveChanges(); LogService.Info(LogTemplates.InfoCrud("Lookup", lookup.Key, lookup.Id, isUpdate ? LogTemplates.EntityAction.Modified : LogTemplates.EntityAction.Added)); return(lookup); }
private AgentViewModel SaveAgent(AgentViewModel vm, string btnAddMap, string ddlDataMaps, string btnAddChrome, string ddlAgentChromes, string dataMapAgentNextOrder, string btnAddSchedule, string ddlDay, string ddlHour, string ddlMinute) { var isUpdate = false; var agent = new Agent(); if (vm.Id > 0) { isUpdate = true; agent = dataFlowDbContext.Agents.FirstOrDefault(x => x.Id == vm.Id); agent.Id = vm.Id; } agent.Name = vm.Name; agent.AgentTypeCode = vm.AgentTypeCode; agent.AgentAction = vm.AgentAction; agent.Url = vm.Url; agent.LoginUrl = vm.LoginUrl; agent.Username = vm.Username; if (vm.Password != null) { agent.Password = Encryption.Encrypt(vm.Password, EncryptionKey); } agent.Directory = vm.Directory ?? GetManualAgentBaseDirectory(agent); agent.FilePattern = vm.FilePattern; agent.Enabled = vm.Enabled; agent.Queue = Guid.NewGuid(); agent.Custom = vm.Custom; if (!isUpdate) { agent.Created = DateTime.Now; } if (btnAddChrome != null && int.TryParse(ddlAgentChromes, out var agentChromeId)) { agent.AgentAgentChromes = new List <AgentAgentChrome> { new AgentAgentChrome { AgentChromeId = agentChromeId } }; } if (btnAddMap != null && int.TryParse(ddlDataMaps, out var dataMapId)) { var lastProcessOrder = Convert.ToInt32(dataMapAgentNextOrder) + 1; agent.DataMapAgents = new List <DataMapAgent> { new DataMapAgent { DataMapId = dataMapId, ProcessingOrder = lastProcessOrder } }; } if (btnAddSchedule != null && int.TryParse(ddlDay, out var day) && int.TryParse(ddlHour, out var hour) && int.TryParse(ddlMinute, out var minute)) { agent.AgentSchedules = new List <AgentSchedule> { new AgentSchedule { Day = day, Hour = hour, Minute = minute } }; } dataFlowDbContext.Agents.AddOrUpdate(agent); dataFlowDbContext.SaveChanges(); var savevm = MapperService.Map <AgentViewModel>(agent); LogService.Info(LogTemplates.InfoCrud("Agent", agent.Name, agent.Id, isUpdate ? LogTemplates.EntityAction.Modified : LogTemplates.EntityAction.Added)); return(savevm); }