Example #1
0
        /// <summary>
        /// To activate or inactivate business days
        /// </summary>
        /// <param name="businessUnit"></param>
        /// <returns></returns>
        public bool ActiveOrInactiveBusinessUnit(BusinessUnitViewModel businessUnit)
        {
            try
            {
                if (businessUnit != null)
                {
                    BusinessModel.BusinessModels.BusinessUnit businessUnitBusines = new BusinessModel.BusinessModels.BusinessUnit()
                    {
                        BusinessUnitCode        = businessUnit.BusinessUnitCode,
                        BusinessUnitName        = businessUnit.BusinessUnitName,
                        BusinessUnitDescription = businessUnit.BusinessUnitDescription,
                        Site = new BusinessModel.BusinessModels.Site()
                        {
                            SiteCode        = businessUnit.Site.SiteCode,
                            SiteDescription = businessUnit.Site.SiteDescription,
                            SiteId          = businessUnit.Site.SiteId,
                            SiteName        = businessUnit.Site.SiteName,
                            RecordStatus    = businessUnit.Site.RecordStatus
                        }
                    };

                    return(_businesssUnitRepository.ActiveOrInactiveBusinessUnit(businessUnitBusines));
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                _logger.Log(ex, LogLevel.Error, ex.Message);
                return(false);
            }
        }
        /// <summary>
        /// Returns the BusinessUnit
        /// </summary>
        /// <returns></returns>
        public List <BusinessModel.BusinessModels.BusinessUnit> GetBusinessUnits()
        {
            try
            {
                List <BusinessModel.BusinessModels.BusinessUnit> businessUnitsDTO = new List <BusinessModel.BusinessModels.BusinessUnit>();

                IEnumerable <DomainModel.DomainModels.BusinessUnit> businessUnits = _m3pactContext.BusinessUnit;
                if (businessUnits != null && businessUnits.Count() > 0)
                {
                    foreach (DomainModel.DomainModels.BusinessUnit businessUnit in businessUnits)
                    {
                        BusinessModel.BusinessModels.BusinessUnit businessUnitDTO = new BusinessModel.BusinessModels.BusinessUnit();
                        businessUnitDTO.ID = businessUnit.BusinessUnitId;
                        businessUnitDTO.BusinessUnitCode        = businessUnit.BusinessUnitCode;
                        businessUnitDTO.BusinessUnitName        = businessUnit.BusinessUnitName;
                        businessUnitDTO.BusinessUnitDescription = businessUnit.BusinessUnitDescription;
                        businessUnitDTO.RecordStatus            = businessUnit.RecordStatus;
                        businessUnitsDTO.Add(businessUnitDTO);
                    }
                }
                return(businessUnitsDTO);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// To activate or inactivate business unit
        /// </summary>
        /// <param name="businessUnit"></param>
        /// <returns></returns>
        public bool ActiveOrInactiveBusinessUnit(BusinessModel.BusinessModels.BusinessUnit businessUnit)
        {
            try
            {
                DomainModel.DomainModels.BusinessUnit business = _m3pactContext.BusinessUnit.FirstOrDefault(bu => bu.BusinessUnitCode == businessUnit.BusinessUnitCode);

                if (business != null)
                {
                    if (business.RecordStatus == DomainConstants.RecordStatusActive)
                    {
                        business.RecordStatus = DomainConstants.RecordStatusInactive;
                    }
                    else
                    {
                        business.RecordStatus = DomainConstants.RecordStatusActive;
                    }
                    _m3pactContext.Update(business);
                    _m3pactContext.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #4
0
        /// <summary>
        /// To get the business units based on list of user-ids.
        /// </summary>
        /// <param name="userIds"></param>
        /// <returns></returns>
        private List <BusinessModel.BusinessModels.BusinessUnit> GetBusinessUnits(List <string> userIds)
        {
            List <BusinessModel.BusinessModels.BusinessUnit> businessUnitListBusiness = null;
            List <BusinessUnit> repositoryBusinessUnitList = _clientsHeatMapRepository.GetClientBusinessUnitsOfUser(userIds);

            if (repositoryBusinessUnitList != null)
            {
                businessUnitListBusiness = new List <BusinessModel.BusinessModels.BusinessUnit>();
                foreach (BusinessUnit businessUnitRepository in repositoryBusinessUnitList)
                {
                    BusinessModel.BusinessModels.BusinessUnit businessUnit = new BusinessModel.BusinessModels.BusinessUnit();
                    businessUnit.ID = businessUnitRepository.BusinessUnitId;
                    businessUnit.BusinessUnitCode        = businessUnitRepository.BusinessUnitCode;
                    businessUnit.BusinessUnitName        = businessUnitRepository.BusinessUnitName;
                    businessUnit.BusinessUnitDescription = businessUnitRepository.BusinessUnitDescription;
                    businessUnitListBusiness.Add(businessUnit);
                }
            }
            return(businessUnitListBusiness);
        }
Example #5
0
 /// <summary>
 /// Saves the Business Units
 /// </summary>
 /// <param name="businessUnits"></param>
 /// <returns></returns>
 public bool SaveBusinessUnits(List <BusinessUnitViewModel> businessUnits)
 {
     try
     {
         List <BusinessModel.BusinessModels.BusinessUnit> businessUnitsDTO = new List <BusinessModel.BusinessModels.BusinessUnit>();
         foreach (BusinessUnitViewModel businessUnit in businessUnits)
         {
             BusinessModel.BusinessModels.BusinessUnit businessUnitDTO = new BusinessModel.BusinessModels.BusinessUnit();
             businessUnitDTO.BusinessUnitCode        = businessUnit.BusinessUnitCode;
             businessUnitDTO.BusinessUnitName        = businessUnit.BusinessUnitName;
             businessUnitDTO.BusinessUnitDescription = businessUnit.BusinessUnitDescription;
             businessUnitDTO.RecordStatus            = businessUnit.RecordStatus;
             businessUnitDTO.ID = businessUnit.ID;
             businessUnitsDTO.Add(businessUnitDTO);
         }
         return(_businesssUnitRepository.SaveBusinessUnits(businessUnitsDTO));
     }
     catch (Exception ex)
     {
         _logger.Log(ex, LogLevel.Error, ex.Message);
         return(false);
     }
 }