public async Task <T> Add(T entity) { _context.Add <T>(entity); await _context.SaveChangesAsync(); return(Get(entity.ID)); }
public async Task <IActionResult> Create([Bind("Id,Name")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> AddCompany([Bind("Id,Name")] Company company) { if (ModelState.IsValid) { _context.Add(company); await _context.SaveChangesAsync(); return(Redirect("~/Projects/SelectCompanies")); } return(Redirect("~/Projects/SelectCompanies")); }
public async Task <IActionResult> Create([Bind("Id,Name,StartDate")] Project project) { if (ModelState.IsValid) { _context.Add(project); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(project)); }
public async Task <IActionResult> Create([Bind("Id,Name,StartDate,FinishDate,Priority,ManagerId,CustomerId,PerformerId")] Project project) { if (ModelState.IsValid) { _context.Add(project); await _context.SaveChangesAsync(); AddEmployeeOnProject((int)project.ManagerId, project.Id); return(RedirectToAction(nameof(Index))); } return(View(project)); }
public int Add(T entity) { _context.Add(entity); return(_context.SaveChanges()); }