public List <ComponentAssetMappingModel> GetComponentAssetMappings() { var getComponents = this._componentAssetMappingRepository.GetComponentAssetMappings(); List <ComponentAssetMappingModel> getAllComponents = new List <ComponentAssetMappingModel>(); getComponents.ForEach(componentmapping => { ComponentAssetMappingModel componentsViewModel = new ComponentAssetMappingModel { ID = componentmapping.ID, ComponentName = componentmapping.Components.ComponentName, ComponentID = componentmapping.ComponentID, ComponentTypeName = componentmapping.ComponentType.Name, AssignedAssetID = componentmapping.AssignedAssetID, ComponentStatusId = componentmapping.ComponentStatusId }; if (componentsViewModel.AssignedAssetID != null && componentsViewModel.ComponentStatusId == (int)ComponentTrackingStatus.Assign) { if (componentmapping.Assets1 != null) { componentsViewModel.AssetName = componentmapping.Assets1.AssetName; } else if (componentmapping.Assets != null) { componentsViewModel.AssetName = componentmapping.Assets.AssetName; } } getAllComponents.Add(componentsViewModel); }); return(getAllComponents); }
public ActionResult UnassignComponents(ComponentAssetMappingModel componentModel) { _componentAssetMappingService.UnassignComponents(componentModel); TempData["Message"] = "Asset unassigned successfully."; TempData["MessageType"] = (int)AlertMessageTypes.Success; return(RedirectToAction("List")); }
public ComponentAssetMappingModel GetComponentAssetMappingByComponentID(int id) { if (id != 0) { var componentmapping = _componentAssetMappingRepository.GetComponentAssetMappingsByComponentID(id).FirstOrDefault(); if (componentmapping != null) { return(GetComponentModel(componentmapping)); } else { var comp = _componentsService.GetComponentsById(id); ComponentAssetMappingModel newmodel = new ComponentAssetMappingModel() { ComponentID = comp.ID, ComponentTypeID = comp.ComponentTypeID, ComponentName = comp.ComponentName, ComponentTypeName = comp.ComponentTypeName }; return(newmodel); } } else { return(new ComponentAssetMappingModel { }); } }
public ComponentAssetMappingModel GetComponentModel(ComponentAssetMapping componentmapping) { var componentStatusID = componentmapping.ComponentStatusId; ComponentAssetMappingModel componetModel = new ComponentAssetMappingModel { ID = componentmapping.ID, ComponentName = componentmapping.Components.ComponentName, ComponentID = componentmapping.ComponentID, ComponentTypeID = componentmapping.Components.ComponentTypeID, ComponentTypeName = componentmapping.Components.ComponentType.Name, }; if (componentStatusID == (int)AMSUtilities.Enums.ComponentTrackingStatus.Assign) { if (componentmapping.Assets != null) { componetModel.AssetName = componentmapping.Assets.AssetName; } else if (componentmapping.Assets1 != null) { componetModel.AssetName = componentmapping.Assets1.AssetName; } } return(componetModel); }
public List <ComponentAssetMappingModel> GetComponentAssetMappings() { var getComponents = this._componentAssetMappingRepository.GetComponentAssetMappings(); List <ComponentAssetMappingModel> getAllComponents = new List <ComponentAssetMappingModel>(); getComponents.ForEach(componentmapping => { ComponentAssetMappingModel componentsViewModel = new ComponentAssetMappingModel(); componentsViewModel.ID = componentmapping.ID; componentsViewModel.ComponentName = componentmapping.Components.ComponentName; componentsViewModel.ComponentID = componentmapping.ComponentID; componentsViewModel.ComponentTypeName = componentmapping.Components.ComponentType.Name; componentsViewModel.AssignedAssetID = componentmapping.AssignedAssetID; componentsViewModel.ComponentStatusId = componentmapping.ComponentStatusId; // componentsViewModel.ComponentStatus = componentmapping.ComponentStatus.Description; if (componentsViewModel.AssignedAssetID != null && componentsViewModel.ComponentStatusId == 1) { componentsViewModel.AssetName = componentmapping.Assets1.AssetName; } getAllComponents.Add(componentsViewModel); }); return(getAllComponents); }
public ComponentAssetMappingModel UnassignComponents(ComponentAssetMappingModel componentAssetMappingModel) { ComponentAssetMapping unassignComponents = _componentAssetMappingRepository.GetComponentAssetMappingByID(componentAssetMappingModel.ID); if (unassignComponents != null) { unassignComponents.ComponentStatusId = Convert.ToInt32(AMSUtilities.Enums.ComponentTrackingStatus.Unassign); unassignComponents.AssignedAssetID = null; } _componentAssetMappingRepository.UpdateComponentAssetMapping(unassignComponents); return(componentAssetMappingModel); }
public ActionResult AssignComponents(int ID) { ComponentAssetMappingModel componentAssetMappingModel = new ComponentAssetMappingModel() { Assets = _componentAssetMappingService.GetDropdownAssets(ID) }; var components = _componentAssetMappingService.GetComponentAssetMappingByComponentID(ID); components.Assets = componentAssetMappingModel.Assets; return(PartialView("../Shared/_AssignComponents", components)); }
public List <ComponentAssetMappingModel> GetComponentAssetMappingsByAssetID(int assetID) { var componentAssets = _componentAssetMappingRepository.GetComponentAssetMappingsByAssetID(assetID); List <ComponentAssetMappingModel> getAllComponents = new List <ComponentAssetMappingModel>(); if (componentAssets != null && componentAssets.Count > 0) { //return componentAssets.Select(cam => new ComponentAssetMappingModel //{ // ID=cam.ID, // ComponentID = cam.ComponentID, // AssignedAssetID = cam.AssignedAssetID, // ActualAssetID = cam.ActualAssetID, // ComponentStatusId = cam.ComponentStatusId, // AssignedBy = cam.AssignedBy, // AssignedDate = cam.AssignedDate, // ComponentTypeID=cam.Components.ComponentTypeID, // AssetCategoryId = cam.Assets.AssetTypes.AssetCategoryID, //}).ToList(); componentAssets.ForEach(cam => { ComponentAssetMappingModel componentsViewModel = new ComponentAssetMappingModel { ID = cam.ID, ComponentID = cam.ComponentID, AssignedAssetID = cam.AssignedAssetID, ActualAssetID = cam.ActualAssetID, ComponentStatusId = cam.ComponentStatusId, AssignedBy = cam.AssignedBy, AssignedDate = cam.AssignedDate, ComponentTypeID = cam.Components.ComponentTypeID }; if (cam.Assets1 != null) { componentsViewModel.AssetCategoryId = cam.Assets1.AssetTypes.AssetCategoryID; } else if (cam.Assets != null) { componentsViewModel.AssetCategoryId = cam.Assets.AssetTypes.AssetCategoryID; } getAllComponents.Add(componentsViewModel); }); return(getAllComponents); } else { return(new List <ComponentAssetMappingModel> { }); } }
public int CreateComponentMapping(ComponentAssetMappingModel componentAssetMappingModel) { ComponentAssetMapping componentMapping = new ComponentAssetMapping { ComponentID = componentAssetMappingModel.ComponentID, ComponentStatusId = componentAssetMappingModel.ComponentStatusId, CreatedBy = componentAssetMappingModel.CreatedBy, CreatedDate = componentAssetMappingModel.CreatedDate, ComponentTypeID = componentAssetMappingModel.ComponentTypeID }; var createComponentMapping = this._componentAssetMappingRepository.CreateComponentAssetMapping(componentMapping); return(createComponentMapping.ID); }
public ComponentAssetMappingModel GetComponentModel(ComponentAssetMapping componentmapping, SelectList ddlassets) { ComponentAssetMappingModel componetModel = new ComponentAssetMappingModel { ID = componentmapping.ID, ComponentName = componentmapping.Components.ComponentName, ComponentID = componentmapping.ComponentID, ComponentTypeID = componentmapping.Components.ComponentTypeID, ComponentTypeName = componentmapping.Components.ComponentType.Name, AssignedAssetID = componentmapping.AssignedAssetID, AssetName = componentmapping.Assets1.AssetName, Assets = ddlassets }; return(componetModel); }
public ComponentAssetMappingModel AssignComponents(ComponentAssetMappingModel componentAssetMappingModel) { ComponentAssetMapping assignComponents = _componentAssetMappingRepository.GetComponentAssetMappingByID(componentAssetMappingModel.ID); if (assignComponents != null) { assignComponents.ID = componentAssetMappingModel.ID; assignComponents.AssignedAssetID = componentAssetMappingModel.AssignedAssetID; assignComponents.AssignedBy = _employeeService.GetEmployeeByCorpId(HttpContext.Current.User.Identity.Name).ID; assignComponents.AssignedDate = DateTime.Now; assignComponents.ComponentStatusId = Convert.ToInt32(AMSUtilities.Enums.ComponentStatus.Assign); } _componentAssetMappingRepository.UpdateComponentAssetMapping(assignComponents); return(componentAssetMappingModel); }
public ActionResult AssignComponents(ComponentAssetMappingModel componentAssetMappingModel) { var componentAssetMapping = _componentAssetMappingService.AssignComponents(componentAssetMappingModel); if (componentAssetMapping.ID != 0) { TempData["Message"] = "Asset assigned successfully."; TempData["MessageType"] = (int)AlertMessageTypes.Success; return(RedirectToAction("List")); } else { TempData["Message"] = "Asset not assigned."; TempData["MessageType"] = (int)AlertMessageTypes.Danger; return(View("List")); } }
public ComponentAssetMappingModel AssignComponents(ComponentAssetMappingModel componentAssetMappingModel) { ComponentAssetMapping assigncomponents = new ComponentAssetMapping { ComponentID = componentAssetMappingModel.ComponentID, AssignedAssetID = componentAssetMappingModel.AssignedAssetID, AssignedBy = _employeeService.GetEmployeeByCorpId(HttpContext.Current.User.Identity.Name).ID, AssignedDate = DateTime.Now, CreatedBy = _employeeService.GetEmployeeByCorpId(HttpContext.Current.User.Identity.Name).ID, CreatedDate = DateTime.Now, ComponentTypeID = componentAssetMappingModel.ComponentTypeID, ComponentStatusId = Convert.ToInt32(AMSUtilities.Enums.ComponentTrackingStatus.Assign), }; _componentAssetMappingRepository.CreateComponentAssetMapping(assigncomponents); return(componentAssetMappingModel); }
public int CreateComponentAssetMapping(ComponentAssetMappingModel componentAssetMapping) { ComponentAssetMapping componentMapping = new ComponentAssetMapping { ComponentID = componentAssetMapping.ComponentID, AssignedAssetID = componentAssetMapping.AssignedAssetID, ActualAssetID = componentAssetMapping.ActualAssetID, ComponentStatusId = componentAssetMapping.ComponentStatusId, CreatedBy = componentAssetMapping.CreatedBy, CreatedDate = componentAssetMapping.CreatedDate, AssignedBy = componentAssetMapping.AssignedBy, AssignedDate = componentAssetMapping.AssignedDate, ComponentTypeID = componentAssetMapping.ComponentTypeID }; var objcomponentMapping = this._componentAssetMappingRepository.CreateComponentAssetMapping(componentMapping); return(objcomponentMapping.ID); }
public int UpdateComponentAssetMapping(ComponentAssetMappingModel componentAssetMapping) { ComponentAssetMapping componentAsset = _componentAssetMappingRepository.GetComponentAssetMappingByID(componentAssetMapping.ID); if (componentAssetMapping.ID == 0) { componentAssetMapping.CreatedDate = DateTime.Now; componentAssetMapping.CreatedBy = (int)componentAssetMapping.AssignedBy; componentAssetMapping.ComponentTypeID = componentAssetMapping.ComponentTypeID; componentAssetMapping.ID = CreateComponentAssetMapping(componentAssetMapping); } else if (componentAsset != null) { componentAsset.ComponentID = componentAssetMapping.ComponentID; componentAsset.AssignedAssetID = componentAssetMapping.AssignedAssetID; componentAsset.ActualAssetID = componentAssetMapping.ActualAssetID; componentAsset.ComponentStatusId = componentAssetMapping.ComponentStatusId; componentAsset.AssignedBy = componentAssetMapping.AssignedBy; componentAsset.AssignedDate = componentAssetMapping.AssignedDate; componentAsset.ComponentTypeID = componentAssetMapping.ComponentTypeID; _componentAssetMappingRepository.UpdateComponentAssetMapping(componentAsset); } return(componentAssetMapping.ID); }