//string FType, string GUID, string Name, string IsStart, string MainKey, string GroupSqlString, string SqlString, string AfterSqlString, string AfterSqlstring2 public async Task <string> SystemKeyAdd([FromBody] SystemKey systemKeyAddIn) { //判断当前是否有重复 if (_SqlLiteContext.SystemKeys.AsNoTracking().Contains(systemKeyAddIn)) { return(System.Text.Json.JsonSerializer.Serialize(new ResponseCommon { msg = "已有重复的项,请检查后重试", code = "-1" })); } Dtos.Models.SystemKey systemKeyAdd = new Dtos.Models.SystemKey { KeyName = systemKeyAddIn.KeyName, KeyValue = systemKeyAddIn.KeyValue }; await _SqlLiteContext.SystemKeys.AddAsync(systemKeyAdd); var addresult = await _SqlLiteContext.SaveChangesAsync(); if (addresult > 0) { return(System.Text.Json.JsonSerializer.Serialize(new ResponseCommon { msg = "", code = "0" })); } else { return(System.Text.Json.JsonSerializer.Serialize(new ResponseCommon { msg = "新增系统变量失败", code = "-1" })); } }
public async Task <string> DataSourceEdit([FromBody] DataSource dataSourceAddIn) { var nowRunningTP = await _sqliteFSql.Select <TaskPlan>().Where(o => o.Status == "1").ToListAsync(); List <string> tPGuids = new List <string>(); foreach (var item in nowRunningTP) { tPGuids.Add(item.GUID); } var nowRuningTPRE = await _sqliteFSql.Select <TaskPlanDetail>().Where(o => tPGuids.Contains(o.TaskPlanGuid) && o.OpenSqlGuid == dataSourceAddIn.GUID).ToListAsync(); if (nowRuningTPRE.Count != 0) { tPGuids.Clear(); return(new ResponseCommon { msg = "此数据源正在执行,不允许修改!", code = "1" }.ToJsonCommon()); } var dsUpdate = await _SqlLiteContext.OpenSql.AsNoTracking().Where(o => o.GUID == dataSourceAddIn.GUID).FirstOrDefaultAsync(); dsUpdate.AfterSqlString = dataSourceAddIn.AfterSqlString; dsUpdate.AfterSqlstring2 = dataSourceAddIn.AfterSqlstring2; dsUpdate.GroupSqlString = dataSourceAddIn.GroupSqlString; dsUpdate.IsStart = string.IsNullOrEmpty(dataSourceAddIn.IsStart) ? "0" : "1"; dsUpdate.MainKey = dataSourceAddIn.MainKey; dsUpdate.SqlString = dataSourceAddIn.SqlString; dsUpdate.Name = dataSourceAddIn.Name; _SqlLiteContext.OpenSql.Update(dsUpdate); var addresult = await _SqlLiteContext.SaveChangesAsync(); if (addresult > 0) { return(System.Text.Json.JsonSerializer.Serialize(new ResponseCommon { msg = "", code = "0" })); } else { return(System.Text.Json.JsonSerializer.Serialize(new ResponseCommon { msg = "修改数据源失败", code = "-1" })); } }
public async Task <IActionResult> Create([Bind("ExpertiseId,Name")] Expertise expertise) { if (ModelState.IsValid) { bool duplicate = false; using var context = new SqlLiteContext(); var expertises = context.Expertises.ToList(); foreach (var entity in expertises) { if (expertise.Name == entity.Name) { duplicate = true; } } if (!duplicate) { context.Add(expertise); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(RedirectToAction("Duplicate", new { name = expertise.Name })); }
public async Task <IActionResult> Edit(int id, [Bind("ExpertiseId,Name")] Expertise expertise) { if (id != expertise.ExpertiseId) { return(NotFound()); } if (ModelState.IsValid) { try { using var context = new SqlLiteContext(); context.Update(expertise); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ExpertiseExists(expertise.ExpertiseId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(expertise)); }
public async Task <IActionResult> Create([Bind("TrainingId,Name,IsDegree")] Training training) { if (ModelState.IsValid) { bool duplicate = false; using var context = new SqlLiteContext(); var trainings = context.Trainings.ToList(); foreach (var entity in trainings) { if (training.Name == entity.Name) { duplicate = true; } } if (!duplicate) { context.Add(training); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(RedirectToAction("Duplicate", new { name = training.Name })); }
public async Task <IActionResult> Edit(int id, [Bind("TrainingId,Name,IsDegree")] Training training) { if (id != training.TrainingId) { return(NotFound()); } if (ModelState.IsValid) { try { var context = new SqlLiteContext(); context.Update(training); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TrainingExists(training.TrainingId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(training)); }
public async Task <IActionResult> Edit(int id, [Bind("CompanyId,CompanyName,ProfileCompanyAdress,ProfileCompanyPostalAdress,City")] Company company) { if (id != company.CompanyId) { return(NotFound()); } if (ModelState.IsValid) { try { using var context = new SqlLiteContext(); context.Update(company); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanyExists(company.CompanyId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(company)); }
public async Task <IActionResult> Create(EmployeeViewModel model) { if (ModelState.IsValid) { string uniqueFileName = UploadedFile(model); Employee employee = new Employee { EmployeeName = model.EmployeeName, EmployeeInfo = model.EmployeeInfo, EmployeRole = model.EmployeRole, Interest = model.Interest, ProfilePicture = uniqueFileName, City = model.City, Tele = model.Tele, Linkedin = model.Linkedin, Mail = model.Mail }; var context = new SqlLiteContext(); context.Add(employee); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View()); }
public async Task <IActionResult> DeleteConfirmed(int id) { var context = new SqlLiteContext(); var assigment = await context.Assigments.FindAsync(id); context.Assigments.Remove(assigment); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> DeleteConfirmed(int id) { using var context = new SqlLiteContext(); var expertise = await context.Expertises.FindAsync(id); context.Expertises.Remove(expertise); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
//string FType, string GUID, string Name, string IsStart, string MainKey, string GroupSqlString, string SqlString, string AfterSqlString, string AfterSqlstring2 public async Task <string> TaskPlanAdd([FromBody] TaskPlanExGuidCode TaskPlanAddIn) { string guid = Guid.NewGuid().ToString(); string code = ""; var isExist = await _SqlLiteContext.TaskPlan.AsNoTracking().OrderByDescending(o => o.CODE).FirstOrDefaultAsync(); if (isExist == null) { code = "100"; } else { code = (int.Parse(isExist.CODE) + 1).ToString(); } Dtos.Models.TaskPlan TaskPlanAdd = new Dtos.Models.TaskPlan { CODE = code, Frequency = TaskPlanAddIn.Frequency, FrequencyType = TaskPlanAddIn.FrequencyType, GUID = guid, Name = TaskPlanAddIn.Name, OrgCode = TaskPlanAddIn.OrgCode, DllOrUrl = TaskPlanAddIn.DllOrUrl, WorkType = TaskPlanAddIn.WorkType }; await _SqlLiteContext.TaskPlan.AddAsync(TaskPlanAdd); var addresult = await _SqlLiteContext.SaveChangesAsync(); if (addresult > 0) { return(System.Text.Json.JsonSerializer.Serialize(new ResponseCommon { msg = "", code = "0" })); } else { return(System.Text.Json.JsonSerializer.Serialize(new ResponseCommon { msg = "新增任务计划失败", code = "-1" })); } }
public async Task <IActionResult> Create([Bind("CompanyId,CompanyName,ProfileCompanyAdress,ProfileCompanyPostalAdress,City")] Company company) { if (ModelState.IsValid) { using var context = new SqlLiteContext(); context.Add(company); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(company)); }
//string FType, string GUID, string Name, string IsStart, string MainKey, string GroupSqlString, string SqlString, string AfterSqlString, string AfterSqlstring2 public async Task <string> OrgAdd([FromBody] Organization organizationAddIn) { //判断当前是否有重复 if (_SqlLiteContext.OrgSetting.AsNoTracking().Contains(organizationAddIn)) { return(System.Text.Json.JsonSerializer.Serialize(new ResponseCommon { msg = "已有重复的项,请检查后重试", code = "-1" })); } string connecting = GetConnectString(organizationAddIn); Dtos.Models.Organization orgCOn = new Dtos.Models.Organization { CODE = organizationAddIn.CODE, NAME = organizationAddIn.NAME, DataBaseName = organizationAddIn.DataBaseName, DBType = organizationAddIn.DBType, Password = organizationAddIn.Password, ServerName = organizationAddIn.ServerName, UserName = organizationAddIn.UserName, ConnectingString = connecting }; await _SqlLiteContext.OrgSetting.AddAsync(orgCOn); var addresult = await _SqlLiteContext.SaveChangesAsync(); if (addresult > 0) { return(System.Text.Json.JsonSerializer.Serialize(new ResponseCommon { msg = "", code = "0" })); } else { return(System.Text.Json.JsonSerializer.Serialize(new ResponseCommon { msg = "新增组织机构失败", code = "-1" })); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Employee,EmployeeId,Uppdrag,Tid,Roll,Beskrivning,Teknik,Focus")] AssignmentViewModel assigmentviewmodel) { if (id != assigmentviewmodel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { Assigment assignment = AssignmentService.Get(assigmentviewmodel.Id); assignment.Id = assigmentviewmodel.Id; assignment.Employeeid = assigmentviewmodel.Employee.EmployeeId; assignment.Beskrivning = assigmentviewmodel.Beskrivning; assignment.Focus = assigmentviewmodel.Focus; assignment.Uppdrag = assigmentviewmodel.Uppdrag; assignment.Roll = assigmentviewmodel.Roll; assignment.Teknik = assigmentviewmodel.Teknik; assignment.Tid = assigmentviewmodel.Tid; var context = new SqlLiteContext(); context.Update(assignment); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AssigmentExists(assigmentviewmodel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View()); }
public async Task <IActionResult> Edit(EmployeeViewModel model) { if (ModelState.IsValid) { Employee employee = EmployeeService.Get(model.EmployeeId); if (model.ProfileImage != null) { string uniqueFileName = UploadedFile(model); employee.ProfilePicture = uniqueFileName; } employee.EmployeeId = model.EmployeeId; employee.City = model.City; employee.Tele = model.Tele; employee.Linkedin = model.Linkedin; employee.Mail = model.Mail; employee.EmployeeName = model.EmployeeName; employee.EmployeeInfo = model.EmployeeInfo; employee.EmployeRole = model.EmployeRole; employee.Interest = model.Interest; try { var context = new SqlLiteContext(); context.Update(employee); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(employee.EmployeeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View()); }
public async Task <IActionResult> Create([Bind("Id,Employeeid,SelectedEmployeeId,Uppdrag,Tid,Roll,Beskrivning,Teknik,Focus")] AssignmentViewModel model) { if (ModelState.IsValid) { Assigment assignment = new Assigment { Employeeid = model.SelectedEmployeeId, Beskrivning = model.Beskrivning, Uppdrag = model.Uppdrag, Focus = model.Focus, Roll = model.Roll, Tid = model.Tid, Teknik = model.Teknik, }; var context = new SqlLiteContext(); context.Add(assignment); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(model)); }