public ActionResult Details(int id) { var asset = _assetRepository.Get(id, "AllocatedUser.Person"); if (asset == null) { return(HttpNotFound()); } var allocations = _assetAllocationRepository.GetAllBy(a => a.AssetId == asset.Id, "AllocatedUser.Person,AllocatedByUser.Person").ToList(); var vm = new AssetDetailsViewModel(asset) { AssetAllocations = allocations }; // If we have snapshots, set snapshot variable var snapshot = _systemSnapshotRepository.GetBy(s => s.AssetId == asset.Id); if (snapshot != null) { vm.HasSoftwareInfo = true; vm.Softwares = JsonConvert.DeserializeObject <List <SoftwareModel> >(snapshot.Softwares); vm.HasHardwareInfo = true; vm.Hardware = JsonConvert.DeserializeObject <HardwareModel>(snapshot.Hardwares); } var assetDocs = _assetDocumentRepository.GetAllBy(a => a.AssetId == asset.Id); vm.AssetDocuments = assetDocs.ToList(); return(View(vm)); }
public ActionResult Index() { var user = _userRepository.GetBy(u => u.Id == WebUser.Id, "Person,AccessRule,ReportingPerson.Person,Manager.Person,Location,Department,Designation,Shift"); var employee = _employeeRepository.GetBy(u => u.UserId == WebUser.Id, "User,User.Person,ReportingPerson.User.Person,Manager.User.Person,Location,Department,Designation,Shift"); var userDocs = _userDocumentRepository.GetAllBy(m => m.UserId == user.Id); var userSkills = _userSkillRepository.GetAllBy(m => m.UserId == user.Id, "Skill"); var userHobbies = _userHobbyRepository.GetAllBy(m => m.UserId == user.Id, "Hobby"); var userCertifications = _userCertificationRepository.GetAllBy(m => m.UserId == user.Id, "Certification"); var roleMembers = _roleMemberRepository.GetAllBy(m => m.UserId == user.Id, "Role").ToList(); var assets = _assetRepository.GetAllBy(u => u.AllocatedEmployeeId == user.Id, "AssetCategory").ToList(); var projects = _projectMemberRepository.GetAllBy(p => p.EmployeeId == user.Id, "Project").ToList(); var technologies = _userTechnologyMapRepository.GetAllBy(r => r.UserId == user.Id, "Technology").Select(t => t.Technology).ToList(); //var emergencyContacts = _emergencyContactRepository.GetAllBy(c => c.UserId == user.Id).ToList(); //var dependants = _employeeDependentRepository.GetAllBy(d => d.UserId == user.Id).ToList(); var reportees = _userRepository.GetAllBy(u => u.EmployeeStatus != EmployeeStatus.Ex && u.ReportingPersonId == WebUser.Id, "Person,Designation,AccessRule").ToList(); var tokens = _tokenRepository.GetAllBy(t => t.AllocatedToUserId == user.Id).ToList(); var awards = _userAwardRepository.GetAllBy(u => u.UserId == user.Id, "Award").ToList(); ViewBag.WebuserId = employee.Id; var userViewModel = new UserViewModel(user) { UserDocuments = userDocs.ToList(), UserSkills = userSkills.ToList(), UserCertifications = userCertifications.ToList(), RoleMembers = roleMembers.ToList(), //Projects = projects.ToList(), Technologies = technologies, //EmergencyContacts = emergencyContacts.ToList(), //EmployeeDependents = dependants.ToList(), Reportees = reportees, //Tokens = tokens, UserHobbies = userHobbies.ToList(), UserAwards = awards }; var linkedAccounts = _linkedAccountRepository.GetAllBy(u => u.UserId == user.Id).ToList(); userViewModel.LinkedAccounts = linkedAccounts.ToList(); // If we have snapshots, set snapshot variable var snapshot = _systemSnapshotRepository.GetBy(s => s.UserId == user.Id); if (snapshot != null) { userViewModel.HasSoftwareInfo = true; userViewModel.Softwares = JsonConvert.DeserializeObject <List <SoftwareModel> >(snapshot.Softwares); userViewModel.HasHardwareInfo = true; userViewModel.Hardware = JsonConvert.DeserializeObject <HardwareModel>(snapshot.Hardwares); } return(View(userViewModel)); }
public ActionResult Create(SystemInfo vm) { var selectedAsset = _assetRepository.GetBy(a => a.TagNumber == vm.AssetId); if (selectedAsset != null && WebUser != null) { var previousSnapShot = _systemSnapshotRepository.GetBy(s => s.UserId == WebUser.Id && s.AssetId == selectedAsset.Id); // No previous snapshots exists if (previousSnapShot == null) { var snapShot = new SystemSnapshot { UserId = WebUser.Id, AssetId = selectedAsset.Id, Softwares = JsonConvert.SerializeObject(vm.Softwares), Hardwares = JsonConvert.SerializeObject(vm.Hardware), RanOn = vm.RanOn }; _systemSnapshotRepository.Create(snapShot); _unitOfWork.Commit(); } else { previousSnapShot.Softwares = JsonConvert.SerializeObject(vm.Softwares); previousSnapShot.Hardwares = JsonConvert.SerializeObject(vm.Hardware); previousSnapShot.RanOn = vm.RanOn; _systemSnapshotRepository.Update(previousSnapShot); _unitOfWork.Commit(); } return(Json(true)); } return(Json(false)); }
public ActionResult Details(int id) { var user = _userRepository.Get(id, "Person,AccessRule,ReportingPerson.Person, Manager.Person, Location,Department,Designation,Shift"); if (user == null) { return(HttpNotFound()); } var userDocs = _userDocumentRepository.GetAllBy(m => m.UserId == user.Id); var userSkills = _userSkillRepository.GetAllBy(m => m.UserId == user.Id, "Skill"); var userHobbies = _userHobbyRepository.GetAllBy(m => m.UserId == user.Id, "Hobby"); var userCertifications = _userCertificationRepository.GetAllBy(m => m.UserId == user.Id, "Certification"); var roleMembers = _roleMemberRepository.GetAllBy(m => m.UserId == user.Id, "Role"); var assets = _assetRepository.GetAllBy(u => u.AllocatedEmployeeId == user.Id, "AssetCategory").ToList(); //var leaveEntitlements = _leaveEntitlementRepository.GetAllBy(u => u.AllocatedUserId == user.Id, "LeaveType").ToList(); var projects = _projectMemberRepository.GetAllBy(p => p.EmployeeId == user.Id, "Project,Member").ToList(); var technologies = _userTechnologyMapRepository.GetAllBy(r => r.UserId == user.Id, "Technology").Select(t => t.Technology).ToList(); //var emergencyContacts = _emergencyContactRepository.GetAllBy(c => c.UserId == user.Id); //var dependants = _employeeDependentRepository.GetAllBy(d => d.UserId == user.Id); var reportees = _userRepository.GetAllBy(u => u.EmployeeStatus != EmployeeStatus.Ex && u.ReportingPersonId == user.Id, "Person,Designation,AccessRule").ToList(); var tokens = _tokenRepository.GetAllBy(t => t.AllocatedToUserId == user.Id).ToList(); var awards = _userAwardRepository.GetAllBy(u => u.UserId == user.Id, "Award").ToList(); var userViewModel = new UserViewModel { Id = user.Id, EmployeeCode = user.EmployeeCode, Username = user.Username, AccessRuleId = user.AccessRuleId, AccessRule = user.AccessRule, PersonId = user.PersonId, Person = user.Person, DepartmentId = user.DepartmentId, Department = user.Department, LocationId = user.LocationId, Location = user.Location, DesignationId = user.DesignationId, Designation = user.Designation, ShiftId = user.ShiftId, Shift = user.Shift, ReportingPersonId = user.ReportingPersonId, ReportingPerson = user.ReportingPerson, ManagerId = user.ManagerId, Manager = user.Manager, Experience = user.Experience, DateOfJoin = user.DateOfJoin, ConfirmationDate = user.ConfirmationDate, LastDate = user.LastDate, DateOfResignation = user.DateOfResignation, OfficialEmail = user.OfficialEmail, EmployeeStatus = user.EmployeeStatus, RequiresTimeSheet = user.RequiresTimeSheet, Salary = user.Salary, Bank = user.Bank, BankAccountNumber = user.BankAccountNumber, PANCard = user.PANCard, PaymentMode = user.PaymentMode, UserDocuments = userDocs.ToList(), UserSkills = userSkills.ToList(), UserCertifications = userCertifications.ToList(), RoleMembers = roleMembers.ToList(), //Assets = assets.ToList(), //LeaveEntitlements = leaveEntitlements.ToList(), //Projects = projects.ToList(), Technologies = technologies, //EmergencyContacts = emergencyContacts.ToList(), //EmployeeDependents = dependants.ToList(), Reportees = reportees, //Tokens = tokens, UserHobbies = userHobbies.ToList(), UserAwards = awards }; // If we have snapshots, set snapshot variable var snapshot = _systemSnapshotRepository.GetBy(s => s.UserId == user.Id); if (snapshot != null) { userViewModel.HasSoftwareInfo = true; userViewModel.Softwares = JsonConvert.DeserializeObject <List <SoftwareModel> >(snapshot.Softwares); userViewModel.HasHardwareInfo = true; userViewModel.Hardware = JsonConvert.DeserializeObject <HardwareModel>(snapshot.Hardwares); } return(View(userViewModel)); }