Пример #1
0
        /// <summary>
        /// Activating or InActivating systems
        /// </summary>
        /// <param name="systemViewModel"></param>
        /// <returns></returns>
        public bool ActivateOrInactivateSystem(SystemViewModel systemViewModel)
        {
            try
            {
                BusinessModel.Admin.System system = new BusinessModel.Admin.System();
                system.SystemCode        = systemViewModel.SystemCode;
                system.ID                = systemViewModel.ID;
                system.SystemDescription = systemViewModel.SystemDescription;
                system.SystemName        = systemViewModel.SystemName;

                return(_systemRepository.ActivateOrInactivateSystems(system));
            }
            catch (Exception ex)
            {
                _logger.Log(ex, LogLevel.Error, ex.Message);
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// To get the systems based on list of user-ids.
        /// </summary>
        /// <param name="userIds"></param>
        /// <returns></returns>
        private List <BusinessModel.Admin.System> GetSystems(List <string> userIds)
        {
            List <BusinessModel.Admin.System>      businessSystemList   = null;
            List <DomainModel.DomainModels.System> repositorySystemList = _clientsHeatMapRepository.GetClientSystemsOfUser(userIds);

            if (repositorySystemList != null)
            {
                businessSystemList = new List <BusinessModel.Admin.System>();
                foreach (DomainModel.DomainModels.System system in repositorySystemList)
                {
                    BusinessModel.Admin.System businessSystem = new BusinessModel.Admin.System();
                    businessSystem.ID                = system.SystemId;
                    businessSystem.SystemCode        = system.SystemCode;
                    businessSystem.SystemName        = system.SystemName;
                    businessSystem.SystemDescription = system.SystemDescription;
                    businessSystemList.Add(businessSystem);
                }
            }
            return(businessSystemList);
        }
Пример #3
0
        /// <summary>
        /// Activating or InActivating systems
        /// </summary>
        /// <param name="system"></param>
        /// <returns></returns>
        public bool ActivateOrInactivateSystems(BusinessModel.Admin.System system)
        {
            try
            {
                DomainModel.DomainModels.System systemDTO = _m3pactContext.System.FirstOrDefault(s => s.SystemCode == system.SystemCode);

                if (systemDTO != null)
                {
                    if (systemDTO.RecordStatus == DomainConstants.RecordStatusActive)
                    {
                        systemDTO.RecordStatus = DomainConstants.RecordStatusInactive;

                        List <Client> clients = _m3pactContext.Client.Where(c => c.SystemId == systemDTO.SystemId && c.IsActive == DomainConstants.RecordStatusActive).ToList();

                        if (clients != null && clients.Count > 0)
                        {
                            foreach (Client c in clients)
                            {
                                c.RecordStatus = DomainConstants.RecordStatusInactive;
                                c.IsActive     = DomainConstants.RecordStatusInactive;
                            }
                            _m3pactContext.UpdateRange(clients);
                        }
                        _m3pactContext.Update(systemDTO);
                    }
                    else
                    {
                        systemDTO.RecordStatus = DomainConstants.RecordStatusActive;
                        _m3pactContext.Update(systemDTO);
                    }

                    _m3pactContext.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
 /// <summary>
 /// Saves the Systems
 /// </summary>
 /// <param name="Systems"></param>
 /// <returns></returns>
 public bool SaveSystems(List <SystemViewModel> Systems)
 {
     try
     {
         List <BusinessModel.Admin.System> SystemsDTO = new List <BusinessModel.Admin.System>();
         foreach (SystemViewModel system in Systems)
         {
             BusinessModel.Admin.System systemDTO = new BusinessModel.Admin.System();
             systemDTO.SystemCode        = system.SystemCode;
             systemDTO.SystemDescription = system.SystemDescription;
             systemDTO.SystemName        = system.SystemName;
             systemDTO.RecordStatus      = system.RecordStatus;
             systemDTO.ID = system.ID;
             SystemsDTO.Add(systemDTO);
         }
         return(_systemRepository.SaveSystems(SystemsDTO));
     }
     catch (Exception ex)
     {
         _logger.Log(ex, LogLevel.Error, ex.Message);
         return(false);
     }
 }