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); }
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(); }
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(); }
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(); }