Пример #1
0
        public void Add(EmployeeCreateModel employeeModel, string email)
        {
            EmployeeRole role = _context.EmployeeRole.FirstOrDefault(r => r.Owner == email && r.Id == employeeModel.RoleId);

            if (role == null)
            {
                throw new Exception("No permission!!!");
            }
            Employee checkId = _context.Employee.FirstOrDefault(e => e.EmployeeCompanyId == employeeModel.EmployeeCompanyId && e.Owner == email);

            if (checkId != null)
            {
                throw new Exception("Id Exist!!!");
            }
            Employee employee = new Employee()
            {
                EmployeeCompanyId = employeeModel.EmployeeCompanyId,
                FullName          = employeeModel.FullName,
                RoleId            = employeeModel.RoleId,
                Owner             = email,
                Manpower          = employeeModel.Manpower,
                Active            = true
            };

            _context.Add(employee);
            _context.SaveChanges();
        }
Пример #2
0
        public void Add(WorkTime model, string email)
        {
            Employee employee = _context.Employee.FirstOrDefault(e => e.Id == model.EmployeeId && e.Owner == email);

            if (employee == null)
            {
                throw new Exception("Decline!!");
            }
            _context.Add(model);
            _context.SaveChanges();
        }
Пример #3
0
        public void Add(string roleName, string email)
        {
            EmployeeRole model = new EmployeeRole()
            {
                Owner       = email,
                Description = roleName,
                Active      = true
            };

            _context.Add(model);
            _context.SaveChanges();
        }
Пример #4
0
        public void AddWorkTime(int empId, double workTime, int projectId, string owner)
        {
            Employee          employee            = _context.Employee.FirstOrDefault(e => e.Id == empId && e.Owner == owner);
            int               employeeInProjectId = _context.EmployeeInProject.FirstOrDefault(e => e.ProjectId == projectId && e.EmployeeId == empId).Id;
            WorkTimeInProject model = new WorkTimeInProject()
            {
                EmployeeInProjectId = employeeInProjectId,
                WorkDate            = DateTime.Now,
                WorkHour            = workTime
            };

            _context.Add(model);
            _context.SaveChanges();
        }
Пример #5
0
        public void Add(ProjectAddModel model, string email)
        {
            Project projectExist = _context.Project.FirstOrDefault(p => p.ProjectCompanyId == model.ProjectCompanyId && p.Email == email);

            if (projectExist != null)
            {
                throw new Exception("Project exist");
            }
            DateTime actualEndDate = new DateTime(2000, 1, 1);

            Project project = new Project()
            {
                Email            = email,
                Description      = model.Description,
                EndDate          = model.EndDate,
                StartDate        = model.StartDate,
                ProjectCompanyId = model.ProjectCompanyId,
                StatusId         = NOT_STARTED,
                ActualEndDate    = actualEndDate
            };

            _context.Project.Add(project);
            _context.SaveChanges();
        }
Пример #6
0
 public void Add(User account)
 {
     _context.User.Add(account);
     _context.SaveChanges();
 }