public async Task <T> Add(T entity)
        {
            _context.Add <T>(entity);
            await _context.SaveChangesAsync();

            return(Get(entity.ID));
        }
예제 #2
0
        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"));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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());
 }