コード例 #1
0
        private void FindOrCreateProject()
        {
            var project = _db.Project.FirstOrDefault(p => p.Name == _projectName);

            if (project == null)
            {
                project = new Project
                {
                    Name = _projectName
                };

                _db.Add(project);
            }

            _project = project;
        }
コード例 #2
0
        public async Task <IActionResult> CreateEmployee([Bind("FirstName,LastName,PTO,Contact,Role,ClockedIn")] Employee employee, [Bind("Address,City,State,Phone")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contact);
                await _context.SaveChangesAsync();

                employee.RoleId = employee.Role.Id;
                employee.Role   = null;

                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction("ManageEmployee"));
            }
            return(RedirectToAction("CreateEmployee"));
        }
コード例 #3
0
        //WIP: this method will create a new request from the logged in user. WORRY ABOUT ERROR HANDLING LATER
        public async Task <IActionResult> AddRequest(Employee employee, int hours, string reason)
        {
            employee = _context.Employees.Where(emp => emp.Id == 33).FirstOrDefault();     //PLACEHOLDER VALUE FOR FUTURE LOGGED IN USER****
            if (employee.Id == 0 || employee == null)
            {
                PTORequest newRequest = new PTORequest
                {
                    Employee = employee,     //not sure if this can be passed as an employee object from the view
                    Hours    = hours,
                    Reason   = reason,
                    Status   = _context.Statuses.Where(stat => stat.Name == "In Process").FirstOrDefault()
                };

                _context.Add(newRequest);
                await _context.SaveChangesAsync();     //comment this line for front-end testing (aka: comment to not flood db)

                return(RedirectToAction("Main", "Home"));
            }
            return(RedirectToAction("Index"));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Role role)
        {
            if (ModelState.IsValid)
            {
                _context.Add(role);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(role));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("Id,Address,City,State,Phone")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contact);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contact));
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("Id,EmployeeId,Hours,Reason")] PTORequest pTORequest)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pTORequest);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "Id", "Id", pTORequest.EmployeeId);
            return(View(pTORequest));
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,PTO,RoleId,ContactId,ClockedIn")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContactId"] = new SelectList(_context.Contacts, "Id", "Id", employee.ContactId);
            ViewData["RoleId"]    = new SelectList(_context.Roles, "Id", "Id", employee.RoleId);
            return(View(employee));
        }
コード例 #8
0
 public void Add(User user)
 {
     _context.Add(user);
     _context.SaveChanges();
 }
コード例 #9
0
 public void Add(Report report)
 {
     _context.Add(report);
     _context.SaveChanges();
 }
コード例 #10
0
 public void Add(Deviation deviation)
 {
     _context.Add(deviation);
     _context.SaveChanges();
 }