/// <summary> /// This method will return the system list on Employee selection /// </summary> /// <param name="objSoftware">Object holding EmployeeId</param> /// <returns>Returns a list of System</returns> public List <BusinessEntities.SystemAllocation> PopulateSystem(SoftwareAllocationVm objSoftware) { using (Data.Model.LicenseManagementMVCEntities DbContext = new LicenseManagementMVCEntities()) { SoftwareBusinessLayer software = new SoftwareBusinessLayer(); List <BusinessEntities.SystemAllocation> systemList = new List <BusinessEntities.SystemAllocation>(); List <Data.Model.SystemAllocation> systemDataList = new List <Data.Model.SystemAllocation>(); systemDataList = (from s in DbContext.SystemAllocations where s.EmployeeId == objSoftware.EmployeeId select s).ToList(); BusinessEntities.SystemAllocation objSystem = new BusinessEntities.SystemAllocation(); foreach (var s in systemDataList) { objSystem = new BusinessEntities.SystemAllocation() { SystemAllocationId = s.SystemAllocationId }; if (!software.checkSoftwareAlreadyAllocated(objSystem.SystemAllocationId, objSoftware.SoftwareId)) { systemList.Add(objSystem); } } return(systemList); } }
/// <summary> /// This method will Load employee name on employee field /// </summary> /// <param name="objSoftware">Object containing SystemAllocationId </param> /// <returns>Returns an object holding employee name</returns> public SoftwareAllocationVm LoadAndDisableEmployee(SoftwareAllocationVm objSoftware) { using (Data.Model.LicenseManagementMVCEntities DbContext = new LicenseManagementMVCEntities()) { var result = (from e in DbContext.Employees join sa in DbContext.SystemAllocations on e.EmployeeId equals sa.EmployeeId where sa.SystemAllocationId == objSoftware.SystemAllocationId select new { EmployeeName = e.FirstName + " " + e.LastName, empId = e.EmployeeId, systemId = sa.SystemAllocationId }).FirstOrDefault(); SoftwareAllocationVm objSoft = new SoftwareAllocationVm(); objSoft = new SoftwareAllocationVm() { EmployeeName = result.EmployeeName, EmployeeId = result.empId, SystemAllocationId = result.systemId }; return(objSoft); } }
/// <summary> /// This method will Show SystemDetails in a grid on Employee selection /// </summary> /// <param name="objEmployee">Object containing EmployeeId of selected employee</param> /// <returns>Object holding systen details of system allocated to selected employee</returns> public List <SoftwareAllocationVm> ShowEmployeeSystemDetails(BusinessEntities.Employee objEmployee) { using (Data.Model.LicenseManagementMVCEntities DbContext = new LicenseManagementMVCEntities()) { var result = from s in DbContext.SystemAllocations join sd in DbContext.SystemDetails on s.SystemDetailsId equals sd.SystemDetailsId join b in DbContext.Brands on sd.BrandId equals b.BrandId join st in DbContext.SystemTypes on sd.SystemTypeId equals st.SystemTypeId where s.EmployeeId == objEmployee.EmployeeId select new { brand = b.BrandName, type = st.SystemTypeName, remarks = s.Remarks, series = sd.Series, processor = sd.Processor, hddSpace = sd.HDDSpace, systemAllocationId = s.SystemAllocationId, allotedDate = s.AllotedDate, releaseDate = s.ReleaseDate, isReleased = s.IsReleased, }; SoftwareAllocationVm objSystemDetails = new SoftwareAllocationVm(); List <SoftwareAllocationVm> systemList = new List <SoftwareAllocationVm>(); foreach (var r in result) { objSystemDetails = new SoftwareAllocationVm() { BrandName = r.brand, Series = r.series, Remarks = r.remarks, Processor = r.processor, HDDSpace = r.hddSpace, SystemType = r.type, SystemAllocationId = r.systemAllocationId, AllotedDate = r.allotedDate, ReleaseDate = r.releaseDate, IsReleased = r.isReleased }; systemList.Add(objSystemDetails); } return(systemList); } }
/// <summary> /// This method will display system details on system selection /// </summary> /// <param name="objSoftware">Object holding SystemAllocationID</param> /// <returns>Returns a list of SystemDetails </returns> public SoftwareAllocationVm ShowSystemDetails(SoftwareAllocationVm objSoftware) { using (Data.Model.LicenseManagementMVCEntities DbContext = new LicenseManagementMVCEntities()) { var result = (from s in DbContext.SystemAllocations join sd in DbContext.SystemDetails on s.SystemDetailsId equals sd.SystemDetailsId join b in DbContext.Brands on sd.BrandId equals b.BrandId join st in DbContext.SystemTypes on sd.SystemTypeId equals st.SystemTypeId where s.SystemAllocationId == objSoftware.SystemAllocationId select new { brand = b.BrandName, type = st.SystemTypeName, remarks = s.Remarks, series = sd.Series, processor = sd.Processor, hddSpace = sd.HDDSpace, systemAllocationId = s.SystemAllocationId, allotedDate = s.AllotedDate, releaseDate = s.ReleaseDate, isReleased = s.IsReleased }).FirstOrDefault(); SoftwareAllocationVm objSystemDetails = new SoftwareAllocationVm() { BrandName = result.brand, Series = result.series, Remarks = result.remarks, Processor = result.processor, HDDSpace = result.hddSpace, SystemType = result.type, SystemAllocationId = result.systemAllocationId }; return(objSystemDetails); } }
/// <summary> /// This method will Allocate Software to user /// </summary> /// <param name="objSoftware">Object holding information neccessory to allocate software</param> /// <returns>Returns a ResultStatus, which reflects the status of operation performed</returns> public ResultStatus SoftwareAllocate(SoftwareAllocationVm objSoftware) { try { using (Data.Model.LicenseManagementMVCEntities DbContext = new LicenseManagementMVCEntities()) { try { Data.Model.SystemInstallation objSoftwareData = new Data.Model.SystemInstallation(); var licenseList = DbContext.Licenses.Where(l => l.SoftwareId == objSoftware.SoftwareId).FirstOrDefault(); if (licenseList != null) { objSoftwareData.LicenseId = licenseList.LicenseId; objSoftwareData.SystemAllocationId = objSoftware.SystemAllocationId; objSoftwareData.InstallationDate = objSoftware.AllotedDate; objSoftwareData.ReleaseDate = objSoftware.ReleaseDate; objSoftwareData.IsReleased = false; DbContext.SystemInstallations.Add(objSoftwareData); DbContext.SaveChanges(); } else { return(ResultStatus.QueryNotExecuted); } } catch (Exception) { return(ResultStatus.QueryNotExecuted); } } } catch (Exception) { return(ResultStatus.ConnectionError); } return(ResultStatus.Success); }