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> 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> 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> 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)); }
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)); }
public void Insert(Cliente obj) { _context.Add(obj); _context.SaveChanges(); }