示例#1
0
        public bool Edit(int id, string email, string description)
        {
            EmployeeRole model = _context.EmployeeRole.First(r => r.Id == id && r.Owner == email);

            if (model == null)
            {
                return(false);
            }
            model.Description = description;
            _context.Update(model);
            _context.SaveChanges();
            return(true);
        }
示例#2
0
        public void Update(EmployeeViewModel employeeModel, string email)
        {
            Employee employee = _context.Employee.FirstOrDefault(e => e.Id == employeeModel.Id && e.Owner == email);

            if (employee == null)
            {
                throw new Exception("No Permission!!!");
            }
            employee.EmployeeCompanyId = employeeModel.EmployeeCompanyId;
            employee.FullName          = employeeModel.FullName;
            employee.RoleId            = employeeModel.RoleId;
            employee.Manpower          = employeeModel.Manpower;
            _context.Update(employee);
            _context.SaveChanges();
        }
        public void Update(WorkTime model, string email)
        {
            WorkTime workTime = _context.WorkTime.FirstOrDefault(w => w.Id == model.Id);
            Employee employee = _context.Employee.FirstOrDefault(e => e.Id == workTime.EmployeeId && e.Owner == email);

            if (employee == null)
            {
                throw new Exception("Decline!!");
            }
            workTime.WorkHour = model.WorkHour;
            _context.Update(workTime);
            _context.SaveChanges();
        }
示例#4
0
        public void ChangeStatus(int id, string email, int statusId)
        {
            Project project = _context.Project.FirstOrDefault(p => p.Email == email && p.Id == id);

            if (project == null)
            {
                throw new Exception("Decline!!");
            }
            project.StatusId = statusId;
            if (statusId == FINISH_STATUS)
            {
                project.ActualEndDate = DateTime.Now;
            }
            _context.Update(project);
            _context.SaveChanges();
        }
示例#5
0
        public void UpdateProfile(string email, UserInfo model)
        {
            User user = _context.User.FirstOrDefault(u => u.Email == email);

            if (!string.IsNullOrEmpty(model.FullName))
            {
                user.FullName = model.FullName;
            }
            if (!string.IsNullOrEmpty(model.PhoneNumber))
            {
                user.PhoneNumber = model.PhoneNumber;
            }
            if (!string.IsNullOrEmpty(model.Address))
            {
                user.Address = model.Address;
            }
            _context.Update(user);
            _context.SaveChanges();
        }