public ActionResult Post([FromBody] Employees employee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Add(employee); _context.SaveChanges(); return(Ok()); }
public async Task <IActionResult> Create([Bind("DepartmentId,DepartmentTitle")] Departments departments) { if (ModelState.IsValid) { _context.Add(departments); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(departments)); }
public async Task <IActionResult> Create([Bind("JobId,JobTitle")] Jobs jobs) { if (ModelState.IsValid) { _context.Add(jobs); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(jobs)); }
public void AddRelatedPerson(PersonModel person, PersonModel relatedPerson, int relationTypeId) { using (var db = new PersonDBContext()) { var model = new PersonToPerson(); model.PersonId = person.Id; model.RelatedPersonId = relatedPerson.Id; model.RelationTypeId = relationTypeId; db.Add(model); db.SaveChanges(); } }
public async Task <IActionResult> Create([Bind("PersonelId,FirstName,LastName,Salary,JobId,DeparmentId")] Employees employees) { if (ModelState.IsValid) { _context.Add(employees); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DeparmentId"] = new SelectList(_context.Departments, "DepartmentId", "DepartmentId", employees.DeparmentId); ViewData["JobId"] = new SelectList(_context.Jobs, "JobId", "JobId", employees.JobId); return(View(employees)); }
public int CreatePerson(PersonModel person) { using (var db = new PersonDBContext()) { var model = new Person { FirstName = person.FirstName, LastName = person.LastName, PersonalNumber = person.PersonalNumber, GenderiD = person.GenderiD, CityId = person.CityId, BirthDate = person.BirthDate, ImagePath = person.ImagePath }; db.Add(model); db.SaveChanges(); return(model.Id); } }
public void Add(Person newperson) { context.Add(newperson); context.SaveChanges(); }