//to remove private AssetManager_Software_View_vm mapEntityToViewSoftwareAsset(AssetManager_Software EFSoftware) { _logger.Debug("Mapping Entity to Software Asset View Model."); var vmSA = new AssetManager_Software_View_vm { SoftwareAssetNumber = EFSoftware.SoftwareAssetNumber, Name = EFSoftware.Name, AccountingReqNumber = EFSoftware.AccountingReqNumber, DateOfPurchase = EFSoftware.DateOfPurchase, ProductOwner = EFSoftware.ServiceDesk_Users3 == null ? "" : (EFSoftware.ServiceDesk_Users3.FirstName + " " + EFSoftware.ServiceDesk_Users3.LastName), ProductUsers = EFSoftware.ServiceDesk_Users4 == null ? "" : (EFSoftware.ServiceDesk_Users4.FirstName + " " + EFSoftware.ServiceDesk_Users4.LastName), Publisher = EFSoftware.ServiceDesk_Users1 == null ? "" : (EFSoftware.ServiceDesk_Users1.FirstName + " " + EFSoftware.ServiceDesk_Users1.LastName), CreatedBy = EFSoftware.ServiceDesk_Users == null ? "" : (EFSoftware.ServiceDesk_Users.FirstName + " " + EFSoftware.ServiceDesk_Users3.LastName), ModifiedBy = EFSoftware.ServiceDesk_Users2 == null ? "" : (EFSoftware.ServiceDesk_Users2.FirstName + " " + EFSoftware.ServiceDesk_Users2.LastName), CreatedDate = EFSoftware.CreatedDate, AssociatedCompany = EFSoftware.AssetManager_Companies == null ? "" : EFSoftware.AssetManager_Companies.Name, EndOfSupportDate = EFSoftware.EndOfSupportDate, LicenseCount = EFSoftware.LicenseCount, Notes = EFSoftware.Notes, ModifiedDate = EFSoftware.ModifiedDate, LicensingInfo = EFSoftware.LicensingInfo, SoftwareType = EFSoftware.AssetManager_Software_AssetType.Name, SupportingCompany = EFSoftware.AssetManager_Companies1 == null ? "" : EFSoftware.AssetManager_Companies1.Name }; return(vmSA); }
private AssetManager_Software mapViewModelToEntitySoftware( AssetManager_Software_vm VMSoftware) { ServiceDesk_Users createdBy = _nsUserRepository.GetUserByUserName(VMSoftware.CreatedByUserName); ServiceDesk_Users modifiedBy = _nsUserRepository.GetUserByUserName(VMSoftware.ModifiedByUserName); ServiceDesk_Users productOwner = _nsUserRepository.GetUserByUserName(VMSoftware.ProductOwnerUserName); ServiceDesk_Users productUser = _nsUserRepository.GetUserByUserName(VMSoftware.ProductUsersUserName); ServiceDesk_Users publisher = _nsUserRepository.GetUserByUserName(VMSoftware.PublisherUserName); var softwareAsset = new AssetManager_Software { SoftwareAssetNumber = VMSoftware.SoftwareAssetNumber, Name = VMSoftware.Name, AccountingReqNumber = VMSoftware.AccountingReqNumber, DateOfPurchase = VMSoftware.DateOfPurchase, CreatedById = createdBy.Id, CreatedDate = VMSoftware.CreatedDate, AssociatedCompanyId = VMSoftware.AssociatedCompanyId, EndOfSupportDate = VMSoftware.EndOfSupportDate, LicenseCount = VMSoftware.LicenseCount, Notes = VMSoftware.Notes, ModifiedById = modifiedBy == null ? (int?)null : modifiedBy.Id, ModifiedDate = VMSoftware.ModifiedDate, LicensingInfo = VMSoftware.LicensingInfo, ProductOwnerId = productOwner == null ? (int?)null : productOwner.Id, ProductUsersId = productUser == null ? (int?)null : productUser.Id, PublisherId = publisher.Id, SoftwareTypeId = VMSoftware.SoftwareTypeId, SupportingCompanyId = VMSoftware.SupportingCompanyId }; return(softwareAsset); }
public int EditSoftwareAsset(int id, AssetManager_Software softwareAsset) { try { var oldSoftwareAsset = GetSoftwareAssetByID(id); if (oldSoftwareAsset != null) { oldSoftwareAsset.AccountingReqNumber = softwareAsset.AccountingReqNumber; oldSoftwareAsset.AssociatedCompanyId = softwareAsset.AssociatedCompanyId; oldSoftwareAsset.DateOfPurchase = softwareAsset.DateOfPurchase; oldSoftwareAsset.EndOfSupportDate = softwareAsset.EndOfSupportDate; oldSoftwareAsset.LicenseCount = softwareAsset.LicenseCount; oldSoftwareAsset.LicensingInfo = softwareAsset.LicensingInfo; oldSoftwareAsset.ModifiedById = softwareAsset.ModifiedById; oldSoftwareAsset.ModifiedDate = softwareAsset.ModifiedDate; oldSoftwareAsset.Name = softwareAsset.Name; oldSoftwareAsset.Notes = softwareAsset.Notes; oldSoftwareAsset.ProductOwnerId = softwareAsset.ProductOwnerId; oldSoftwareAsset.ProductUsersId = softwareAsset.ProductUsersId; oldSoftwareAsset.PublisherId = softwareAsset.PublisherId; oldSoftwareAsset.SoftwareTypeId = softwareAsset.SoftwareTypeId; oldSoftwareAsset.SupportingCompanyId = softwareAsset.SupportingCompanyId; } _context.SaveChanges(); _logger.Info("Software Asset with asset number" + id + " was updated."); return(softwareAsset.Id); } catch (Exception ex) { _logger.Error(ex); return(0); } }
public int CreateSoftwareAsset(AssetManager_Software softwareAsset) { softwareAsset.SoftwareAssetNumber = GetNextSoftwareAssetNumber(); _context.AssetManager_Software.Add(softwareAsset); _context.SaveChanges(); return(softwareAsset.Id); }
private AssetManager_Software_vm mapEntityToViewSoftware( AssetManager_Software EFSoftware) { _logger.Debug("Mapping Entity to Software Asset View Model."); var vmSA = new AssetManager_Software_vm { SoftwareAssetNumber = EFSoftware.SoftwareAssetNumber, Name = EFSoftware.Name, AccountingReqNumber = EFSoftware.AccountingReqNumber, DateOfPurchase = EFSoftware.DateOfPurchase, CreatedByUserName = EFSoftware.ServiceDesk_Users == null ? null : EFSoftware.ServiceDesk_Users.UserName, CreatedDate = EFSoftware.CreatedDate, AssociatedCompanyId = EFSoftware.AssociatedCompanyId, EndOfSupportDate = EFSoftware.EndOfSupportDate, LicenseCount = EFSoftware.LicenseCount, Notes = EFSoftware.Notes, ModifiedByUserName = EFSoftware.ServiceDesk_Users2 == null ? null : EFSoftware.ServiceDesk_Users2.UserName, ModifiedDate = EFSoftware.ModifiedDate, LicensingInfo = EFSoftware.LicensingInfo, ProductOwnerUserName = EFSoftware.ServiceDesk_Users3 == null ? null : EFSoftware.ServiceDesk_Users3.UserName, ProductUsersUserName = EFSoftware.ServiceDesk_Users4 == null ? null : EFSoftware.ServiceDesk_Users4.UserName, PublisherUserName = EFSoftware.ServiceDesk_Users1 == null ? null : EFSoftware.ServiceDesk_Users1.UserName, SoftwareTypeId = EFSoftware.SoftwareTypeId, SupportingCompanyId = EFSoftware.SupportingCompanyId, ProductOwner = EFSoftware.ServiceDesk_Users3 == null ? null : new Software_Users() { SID = EFSoftware.ServiceDesk_Users3.SID, UserName = EFSoftware.ServiceDesk_Users3.UserName, DisplayName = EFSoftware.ServiceDesk_Users3.FirstName + " " + EFSoftware.ServiceDesk_Users3.LastName }, ProductUser = EFSoftware.ServiceDesk_Users4 == null ? null : new Software_Users() { SID = EFSoftware.ServiceDesk_Users4.SID, UserName = EFSoftware.ServiceDesk_Users4.UserName, DisplayName = EFSoftware.ServiceDesk_Users4.FirstName + " " + EFSoftware.ServiceDesk_Users4.LastName }, Publisher = EFSoftware.ServiceDesk_Users1 == null ? null : new Software_Users() { SID = EFSoftware.ServiceDesk_Users1.SID, UserName = EFSoftware.ServiceDesk_Users1.UserName, DisplayName = EFSoftware.ServiceDesk_Users1.FirstName + " " + EFSoftware.ServiceDesk_Users1.LastName }, CreatedBy = EFSoftware.ServiceDesk_Users == null ? null : new Software_Users() { SID = EFSoftware.ServiceDesk_Users.SID, UserName = EFSoftware.ServiceDesk_Users.UserName, DisplayName = EFSoftware.ServiceDesk_Users.FirstName + " " + EFSoftware.ServiceDesk_Users.LastName }, ModifiedBy = EFSoftware.ServiceDesk_Users2 == null ? null : new Software_Users() { SID = EFSoftware.ServiceDesk_Users2.SID, UserName = EFSoftware.ServiceDesk_Users2.UserName, DisplayName = EFSoftware.ServiceDesk_Users2.FirstName + " " + EFSoftware.ServiceDesk_Users2.LastName }, }; return(vmSA); }
public AssetManager_Software GetSoftwareAssetByID(int id) { AssetManager_Software software = _context.AssetManager_Software.FirstOrDefault(x => x.SoftwareAssetNumber == id); return(software); }