/// <summary> /// Save Material Type /// </summary> /// <param name="materialTypeDetails"></param> /// <returns></returns> public int SaveMaterialType(MaterialTypeDTO materialTypeDetails) { materialtype materialtypeEntity = new materialtype(); AutoMapper.Mapper.Map(materialTypeDetails, materialtypeEntity); ESalesUnityContainer.Container.Resolve<IGenericRepository<materialtype>>().Save(materialtypeEntity); IList<AgentDTO> listAgentDTO = ESalesUnityContainer.Container.Resolve<IAgentService>().GetAgentList(); AgentMaterialPercentageDTO objAgentMaterialPercentageDTO = new AgentMaterialPercentageDTO(); foreach (AgentDTO agent in listAgentDTO) { objAgentMaterialPercentageDTO.AMP_Agent_Id = agent.Agent_Id; objAgentMaterialPercentageDTO.AMP_MaterialType_Id = materialtypeEntity.MaterialType_Id; objAgentMaterialPercentageDTO.AMP_IsActive = true; objAgentMaterialPercentageDTO.AMP_CreatedBy = materialtypeEntity.MaterialType_CreatedBy; ESalesUnityContainer.Container.Resolve<IAgentMaterialPercentageService>() .SaveAgentMaterialPercentage(objAgentMaterialPercentageDTO); } return materialtypeEntity.MaterialType_Id; }
private void Fixupmaterialtype(materialtype previousValue) { if (previousValue != null && previousValue.bookings.Contains(this)) { previousValue.bookings.Remove(this); } if (materialtype != null) { if (!materialtype.bookings.Contains(this)) { materialtype.bookings.Add(this); } if (Booking_MaterialType_Id != materialtype.MaterialType_Id) { Booking_MaterialType_Id = materialtype.MaterialType_Id; } } }
private void Fixupmaterialtype(materialtype previousValue) { if (previousValue != null && previousValue.agentmaterialpercentages.Contains(this)) { previousValue.agentmaterialpercentages.Remove(this); } if (materialtype != null) { if (!materialtype.agentmaterialpercentages.Contains(this)) { materialtype.agentmaterialpercentages.Add(this); } if (AMP_MaterialType_Id != materialtype.MaterialType_Id) { AMP_MaterialType_Id = materialtype.MaterialType_Id; } } }
private void Fixupmaterialtype(materialtype previousValue) { if (previousValue != null && previousValue.customermaterialmaps.Contains(this)) { previousValue.customermaterialmaps.Remove(this); } if (materialtype != null) { if (!materialtype.customermaterialmaps.Contains(this)) { materialtype.customermaterialmaps.Add(this); } if (Cust_Mat_MaterialId != materialtype.MaterialType_Id) { Cust_Mat_MaterialId = materialtype.MaterialType_Id; } } }
private void Fixupmaterialtype(materialtype previousValue) { if (previousValue != null && previousValue.dcamaterialallocations.Contains(this)) { previousValue.dcamaterialallocations.Remove(this); } if (materialtype != null) { if (!materialtype.dcamaterialallocations.Contains(this)) { materialtype.dcamaterialallocations.Add(this); } if (DCAMA_MaterialType_Id != materialtype.MaterialType_Id) { DCAMA_MaterialType_Id = materialtype.MaterialType_Id; } } }
/// <summary> /// Update Material Type /// </summary> /// <param name="materialTypeDetails"></param> /// <returns></returns> public int UpdateMaterialType(MaterialTypeDTO materialTypeDetails) { materialtype materialtypeEntity = new materialtype(); materialtype_history materialtypehistoryEntity = new materialtype_history(); int materialid; using (TransactionScope transactionScope = new TransactionScope()) { AutoMapper.Mapper.Map(materialTypeDetails, materialtypeEntity); ESalesUnityContainer.Container.Resolve<IGenericRepository<materialtype>>().Update(materialtypeEntity); materialid = materialTypeDetails.MaterialType_Id; materialTypeDetails.MaterialType_Id = 0; AutoMapper.Mapper.Map(materialTypeDetails, materialtypehistoryEntity); ESalesUnityContainer.Container.Resolve<IGenericRepository<materialtype_history>>().Save(materialtypehistoryEntity); transactionScope.Complete(); } return materialid; }