Esempio n. 1
0
        /// <summary>
        /// Gets the solution header details in project.
        /// </summary>
        /// <param name="projectRequestDto">The project request dto.</param>
        /// <returns></returns>
        /// <exception cref="PowerDesignProException">
        /// ProjectNotFound
        /// or
        /// SolutionNotFound
        /// or
        /// ProjectNotFound
        /// </exception>
        public IEnumerable <SolutionHeaderDetailsInProjectDto> GetSolutionHeaderDetailsInProject(SearchProjectRequestDto projectRequestDto, string userName)
        {
            if (!string.IsNullOrEmpty(projectRequestDto.UserID) && projectRequestDto.ID > 0)
            {
                var projectDetail = _projectRepository.GetSingle(p => p.Active && p.UserID == projectRequestDto.UserID && p.ID == projectRequestDto.ID);

                if (projectDetail == null)
                {
                    return(SharedProjectSolutionDetail(projectRequestDto, userName));

                    throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard);
                }

                var solutionList = projectDetail.Solutions.Where(x => x.Active && userName.Equals(x.OwnedBy, StringComparison.InvariantCultureIgnoreCase)).OrderByDescending(s => s.ModifiedDateTime)
                                   .Select(solution =>
                {
                    var solutionDetail = _solutionEntityToSolutionHeaderDetailsDtoMapper.AddMap(solution);
                    solutionDetail.IsReadOnlyAccess = false;
                    return(solutionDetail);
                });

                if (solutionList == null || solutionList.Count() == 0)
                {
                    return(new List <SolutionHeaderDetailsInProjectDto>());
                }

                return(solutionList);
            }

            throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard);
        }
        /// <summary>
        /// Get solution setup for existing solution
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="projectID"></param>
        /// <param name="solutionID"></param>
        /// <returns></returns>
        public ProjectSolutionDto LoadSolutionSetupForExistingSolution(string userID, int projectID, int solutionID, string userName = "")
        {
            var solution = _solutionRepository.GetSingle(x => x.ID == solutionID && x.ProjectID == projectID && x.Active);

            var readOnlyAccess = false;

            if (!string.IsNullOrEmpty(solution.OwnedBy))
            {
                if (!solution.OwnedBy.Equals(userName, StringComparison.InvariantCultureIgnoreCase))
                {
                    readOnlyAccess = true;
                }
                else
                {
                    readOnlyAccess = false;
                }
            }
            else
            {
                readOnlyAccess = true;
            }

            var response = new ProjectSolutionDto
            {
                ProjectID            = solution.ProjectID,
                SolutionID           = solution.ID,
                SolutionName         = solution.SolutionName,
                SpecRefNumber        = solution.SpecRefNumber,
                Description          = solution.Description,
                IsReadOnlyAccess     = readOnlyAccess,
                BaseSolutionSetupDto = new BaseSolutionSetupDto()
            };

            var solutionSetup = solution.SolutionSetup.FirstOrDefault();

            if (solutionSetup != null)
            {
                var solutionDetail = _solutionSetupToProjectSolutionSetupResponseDtoMapper.AddMap(solution.SolutionSetup.FirstOrDefault());
                response.BaseSolutionSetupDto = new BaseSolutionSetupDto {
                    SolutionSetupMappingValuesDto = solutionDetail
                };

                if (!string.IsNullOrEmpty(solutionSetup.RegulatoryFilter))
                {
                    response.BaseSolutionSetupDto.SolutionSetupMappingValuesDto.SelectedRegulatoryFilterList = solutionSetup
                                                                                                               .RegulatoryFilter.Split(';').Select(x => new RegulatoryFilterDto
                    {
                        Id          = Convert.ToInt32(x.Split(':')[0]),
                        ItemName    = x.Split(':').Length > 1 ? x.Split(':')[1]:"",
                        LanguageKey = x.Split(':').Length > 2 ? x.Split(':')[2]: string.Concat("tregulatoryFilterList.", x.Split(':')[1].Replace(" ", ""))
                    });
                }
            }

            return(response);
        }
        public async Task <CoCFileId> Upload(Stream stream)
        {
            var parts = await _fileSplitter.SplitData(2, stream);

            var fileId    = _mapper.AddMap(parts);
            var cocStatus = _cocService.Upload(parts);
            await Task.Delay(20);

            return(null);
        }
        /// <summary>
        /// Get default solution setup when user is creating a new solution
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="projectID"></param>
        /// <returns></returns>
        public BaseSolutionSetupDto LoadDefaultSolutionSetupForNewSolution(string userID, int projectID)
        {
            var userDefaultSettings = _userDefaultSolutionSetupRepository.GetSingle(x => x.UserID == userID);
            var defaultSolutionSetupMappingForNewSolution = _userDefaultSolutionSetupToBaseSolutionSetupMappingValuesDtoMapper.AddMap(userDefaultSettings);

            if (!string.IsNullOrEmpty(userDefaultSettings.RegulatoryFilter))
            {
                defaultSolutionSetupMappingForNewSolution.SelectedRegulatoryFilterList = userDefaultSettings
                                                                                         .RegulatoryFilter.Split(';').Select(x => new RegulatoryFilterDto
                {
                    Id          = Convert.ToInt32(x.Split(':')[0]),
                    ItemName    = x.Split(':').Length > 1 ? x.Split(':')[1] : "",
                    LanguageKey = x.Split(':').Length > 2 ? x.Split(':')[2] : string.Concat("tregulatoryFilterList.", x.Split(':')[1].Replace(" ", ""))
                });
            }

            return(new BaseSolutionSetupDto
            {
                SolutionSetupMappingValuesDto = defaultSolutionSetupMappingForNewSolution
            });
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the project detail.
        /// </summary>
        /// <param name="searchDto">The search dto.</param>
        /// <param name="userName">Name of the user.</param>
        /// <returns></returns>
        /// <exception cref="PowerDesignProException">
        /// ProjectNotFound
        /// or
        /// ProjectNotFound
        /// </exception>
        public ProjectDetailDto GetProjectDetail(SearchProjectRequestDto searchDto, string userName)
        {
            if (!string.IsNullOrEmpty(searchDto.UserID) && searchDto.ID > 0)
            {
                var projectDetail = _projectRepository.GetSingle(p => p.Active && p.UserID == searchDto.UserID && p.ID == searchDto.ID);

                if (projectDetail == null)
                {
                    return(SharedProjectDetail(searchDto, userName));

                    throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard);
                }

                var projectDetailDto = _projectEntityToProjectDetailDtoMapper.AddMap(projectDetail, userName: userName);
                projectDetailDto.IsReadOnlyAccess = false;

                return(projectDetailDto);
            }

            throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard);
        }
Esempio n. 6
0
        public ACLoadDto GetLoadDetailsForACLoad(SearchBaseLoadRequestDto searchACLoadDto, string userName)
        {
            var solutionLoadDefaultDetail = _loadDefaultsRepository.GetSingle(l => l.LoadID == searchACLoadDto.LoadID);

            if (solutionLoadDefaultDetail == null)
            {
                throw new PowerDesignProException("LoadNotFound", Message.SolutionLoad);
            }

            var voltageFrequencyDetail = _solutionSetupRepository.GetAll(x => x.SolutionID == searchACLoadDto.SolutionID)
                                         .Select(r =>
                                                 new
            {
                VoltageSpecific = r.VoltageSpecific.Value,
                Frequency       = r.Frequency.Value
            }).FirstOrDefault();

            var voltageSpecific = voltageFrequencyDetail.VoltageSpecific;
            var frequency       = voltageFrequencyDetail.Frequency;

            solutionLoadDefaultDetail.ID = 0;
            if (searchACLoadDto.ID != 0)
            {
                var acLoadDetail = _acLoadRepository.GetSingle(x => x.ID == searchACLoadDto.ID);

                if (acLoadDetail == null)
                {
                    throw new PowerDesignProException("ACLoadNotFound", Message.SolutionLoad);
                }

                var result = _acLoadEntityToacLoadDtoMapper.AddMap(acLoadDetail, userName: userName);
                result.VoltageSpecific = int.Parse(voltageSpecific);
                result.Frequency       = int.Parse(frequency);

                return(result);
            }
            else
            {
                var result = _loadDefaultsEntityToACLoadDtoMapper.AddMap(solutionLoadDefaultDetail);
                if (result != null)
                {
                    var countLoad = _acLoadRepository.GetAll(x => x.LoadID == solutionLoadDefaultDetail.LoadID && x.SolutionID == searchACLoadDto.SolutionID).Count();
                    result.Description = string.Concat(solutionLoadDefaultDetail.Load.Description, " #", countLoad + 1);

                    result.VoltageSpecific = int.Parse(voltageSpecific);
                    result.Frequency       = int.Parse(frequency);

                    return(result);
                }
            }

            return(new ACLoadDto());
        }
Esempio n. 7
0
        private MotorLoadDto AddSolutionMotorLoad(MotorLoadDto motorLoadDto, string userID, string userName)
        {
            var solutionLoad = _addMotorLoadDtoToEntityMapper.AddMap(motorLoadDto, userID, userName);

            solutionLoad.CreatedDateTime  = DateTime.UtcNow;
            solutionLoad.CreatedBy        = userName;
            solutionLoad.ModifiedDateTime = DateTime.UtcNow;
            solutionLoad.ModifiedBy       = userName;

            var solutionLoadDetail = _motorLoadRepository.Add(solutionLoad);

            _motorLoadRepository.Commit();

            return(new MotorLoadDto
            {
                ID = solutionLoadDetail.ID,
                Description = solutionLoadDetail.Description
            });
        }
Esempio n. 8
0
        /// <summary>
        /// Adds the project.
        /// </summary>
        /// <param name="addProjectDto">The add project dto.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="userName">Name of the user.</param>
        /// <returns></returns>
        /// <exception cref="PowerDesignProException">ProjectNameExist</exception>
        public AddProjectResponseDto AddProject(AddProjectDto addProjectDto, string userId, string userName)
        {
            var projectCount = _projectRepository.GetAll(p => p.UserID == userId && p.Active)
                               .Where(p => p.ProjectName.ToUpper() == addProjectDto.ProjectName.ToUpper())
                               .Count();

            if (projectCount > 0)
            {
                throw new PowerDesignProException("ProjectNameExist", Message.ProjectDashboard);
            }

            var project = _addProjectDtoToEntityMapper.AddMap(addProjectDto, userId, userName);

            var projectDetail = _projectRepository.Add(project);

            _projectRepository.Commit();

            return(new AddProjectResponseDto
            {
                ProjectID = projectDetail.ID,
                ProjectName = projectDetail.ProjectName
            });
        }
        /// <summary>
        /// Adds the solution detail.
        /// </summary>
        /// <param name="solutionRequestDto">The solution request dto.</param>
        /// <param name="solutions">The solutions.</param>
        /// <returns></returns>
        /// <exception cref="PowerDesignProException">SolutionNameExist</exception>
        private ProjectSolutionDto AddSolutionDetail(ProjectSolutionDto solutionRequestDto, IQueryable <Solution> solutions, string userName)
        {
            var solutionCount = solutions.Count(s => s.SolutionName.Equals(solutionRequestDto.SolutionName, StringComparison.InvariantCultureIgnoreCase) && s.Active);

            if (solutionCount > 0)
            {
                throw new PowerDesignProException("SolutionNameExist", Message.ProjectSolution);
            }

            // mapping Solution child Entity (SolutionSetup)
            var solutionSetupEntity = _solutionSetupRequestDtoToSolutionSetupEntityMapper.AddMap(solutionRequestDto.BaseSolutionSetupDto.SolutionSetupMappingValuesDto);

            solutionSetupEntity.RegulatoryFilter = string.Join(";",
                                                               solutionRequestDto.BaseSolutionSetupDto.SolutionSetupMappingValuesDto.SelectedRegulatoryFilterList.Select(x => x.Id + ":" + x.ItemName + ":" + x.LanguageKey).ToArray());

            // mapping solution entity
            var solutionEntity = _solutionRequestDtoToSolutionEntityMapper.AddMap(solutionRequestDto, null, userName);

            solutionEntity.SolutionSetup.Add(solutionSetupEntity);

            // update Project when add solution
            var Project = _projectRepository.Find(solutionRequestDto.ProjectID);

            Project.ModifiedBy       = solutionEntity.ModifiedBy;
            Project.ModifiedDateTime = solutionEntity.ModifiedDateTime;

            var result         = _solutionRepository.Add(solutionEntity);
            var updatedProject = _projectRepository.Update(Project);

            _solutionRepository.Commit();
            _projectRepository.Commit();

            return(new ProjectSolutionDto
            {
                SolutionID = result.ID
            });
        }
        /// <summary>
        /// Save User Default Solution Setup details
        /// </summary>
        /// <param name="userDefaultSolutionSetupDto"></param>
        /// <param name="userID"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public Boolean SaveUserDefaultSolutionSetup(UserDefaultSolutionSetupDto userDefaultSolutionSetupDto, string userID, string userName)
        {
            var userDefaultSetupCount = _userDefaultSolutionSetupRepository.GetAll(u => !u.IsGlobalDefaults && u.UserID == userID).Count();

            if (userDefaultSetupCount == 0)
            {
                var newUserDefaultSolutionSetup = _userDefaultSolutionSetupDtoToUserDefaultSolutionSetupEntityMapper.AddMap(userDefaultSolutionSetupDto);

                newUserDefaultSolutionSetup.UserID           = userID;
                newUserDefaultSolutionSetup.CreatedDateTime  = DateTime.UtcNow;
                newUserDefaultSolutionSetup.CreatedBy        = userName;
                newUserDefaultSolutionSetup.ModifiedDateTime = DateTime.UtcNow;
                newUserDefaultSolutionSetup.ModifiedBy       = userName;
                newUserDefaultSolutionSetup.RegulatoryFilter = string.Join(";",
                                                                           userDefaultSolutionSetupDto.SelectedRegulatoryFilterList.Select(x => x.Id + ":" + x.ItemName + ":" + x.LanguageKey).ToArray());

                var newAddResult = _userDefaultSolutionSetupRepository.Add(newUserDefaultSolutionSetup);
                _userDefaultSolutionSetupRepository.Commit();

                return(true);
            }

            var userDefaultSolutionSetup = _userDefaultSolutionSetupRepository.GetSingle(u => !u.IsGlobalDefaults && u.UserID == userID);

            _userDefaultSolutionSetupDtoToUserDefaultSolutionSetupEntityMapper.UpdateMap(userDefaultSolutionSetupDto, userDefaultSolutionSetup);

            userDefaultSolutionSetup.ModifiedDateTime = DateTime.UtcNow;
            userDefaultSolutionSetup.ModifiedBy       = userName;
            userDefaultSolutionSetup.RegulatoryFilter = string.Join(";",
                                                                    userDefaultSolutionSetupDto.SelectedRegulatoryFilterList.Select(x => x.Id + ":" + x.ItemName + ":" + x.LanguageKey).ToArray());

            var result = _userDefaultSolutionSetupRepository.Update(userDefaultSolutionSetup);

            _userDefaultSolutionSetupRepository.Commit();

            return(true);
        }
Esempio n. 11
0
        public BasicLoadDto GetLoadDetailsForBasicLoad(SearchBaseLoadRequestDto searchBasicLoadDto, string userName)
        {
            var solutionLoadDefaultDetail = _loadDefaultsRepository.AllIncluding(x => x.HarmonicDeviceType)
                                            .Where(l => l.LoadID == searchBasicLoadDto.LoadID).FirstOrDefault();

            var voltageFrequencyDetail = _solutionSetupRepository.GetAll(x => x.SolutionID == searchBasicLoadDto.SolutionID)
                                         .Select(r =>
                                                 new
            {
                r.VoltagePhaseID,
                r.VoltageNominalID,
                r.VoltageSpecificID,
                r.FrequencyID,
                r.Frequency.Value
            }).FirstOrDefault();

            if (solutionLoadDefaultDetail == null)
            {
                throw new PowerDesignProException("LoadNotFound", Message.SolutionLoad);
            }
            solutionLoadDefaultDetail.ID = 0;
            if (searchBasicLoadDto.ID != 0)
            {
                var basicLoadDetail = _basicLoadRepository.GetSingle(x => x.ID == searchBasicLoadDto.ID);

                if (basicLoadDetail == null)
                {
                    throw new PowerDesignProException("BasicLoadNotFound", Message.SolutionLoad);
                }


                var result = _basicLoadEntityToBasicLoadDtoMapper.AddMap(basicLoadDetail, userName: userName);

                result.FrequencyID = voltageFrequencyDetail.FrequencyID;
                result.Frequency   = Convert.ToInt32(voltageFrequencyDetail.Value);
                //result.HarmonicContentID = solutionLoadDefaultDetail.HarmonicDeviceType.HarmonicContentID;

                result.RunningPFEditable    = solutionLoadDefaultDetail.RunningPFEditable;
                result.SizeStartingEditable = solutionLoadDefaultDetail.SizeStartingEditable;
                result.SizeRunningEditable  = solutionLoadDefaultDetail.SizeRunningEditable;
                result.StartingPFEditable   = solutionLoadDefaultDetail.StartingPFEditable;
                result.HarmonicTypeEditable = solutionLoadDefaultDetail.HarmonicTypeEditable;
                result.StartingMethodID     = solutionLoadDefaultDetail.StartingMethodID;

                result.PFStarting = basicLoadDetail.StartingPF != null?Convert.ToDecimal(basicLoadDetail.StartingPF.Value) : 0;

                result.PFRunning = basicLoadDetail.RunningPF != null?Convert.ToDecimal(basicLoadDetail.RunningPF.Value) : 0;

                result.SizeRunningUnits  = basicLoadDetail.SizeRunningUnits?.Value;
                result.SizeStartingUnits = basicLoadDetail.SizeRunningUnits?.Value;
                result.VoltagePhase      = basicLoadDetail.VoltagePhase != null?Convert.ToInt32(basicLoadDetail.VoltagePhase.Value) : 0;

                result.VoltageSpecific = basicLoadDetail.VoltageSpecific != null?Convert.ToInt32(basicLoadDetail.VoltageSpecific.Value) : 0;

                result.LoadSequenceType = basicLoadDetail.Sequence?.SequenceType.Value;

                return(result);
            }
            else
            {
                var result = _loadDefaultsEntityToBasicLoadDtoMapper.AddMap(solutionLoadDefaultDetail);
                if (result != null)
                {
                    var countLoad = _basicLoadRepository.GetAll(x => x.LoadID == solutionLoadDefaultDetail.LoadID && x.SolutionID == searchBasicLoadDto.SolutionID).Count();
                    result.Description = string.Concat(solutionLoadDefaultDetail.Load.Description, " #", countLoad + 1);

                    var voltageNominalSpecificLoads = GetVoltageNominalSpecificForLoads(voltageFrequencyDetail.VoltageNominalID, voltageFrequencyDetail.VoltageSpecificID, voltageFrequencyDetail.VoltagePhaseID,
                                                                                        voltageFrequencyDetail.FrequencyID);
                    result.VoltagePhaseID    = voltageFrequencyDetail.VoltagePhaseID;
                    result.VoltageNominalID  = voltageNominalSpecificLoads.VoltageNominalID;
                    result.VoltageSpecificID = voltageNominalSpecificLoads.VoltageSpecificID;
                    result.FrequencyID       = voltageFrequencyDetail.FrequencyID;
                    result.Frequency         = Convert.ToInt32(voltageFrequencyDetail.Value);
                    result.HarmonicContentID = solutionLoadDefaultDetail.HarmonicDeviceType.HarmonicContentID;
                    result.StartingMethodID  = solutionLoadDefaultDetail.StartingMethodID;

                    return(result);
                }
            }

            return(new BasicLoadDto());
        }
Esempio n. 12
0
        public MotorLoadDto GetLoadDetailsForMotorLoad(SearchBaseLoadRequestDto searchMotorLoadDto, string userName)
        {
            var solutionLoadDefaultDetail = _loadDefaultsRepository.GetSingle(l => l.LoadID == searchMotorLoadDto.LoadID);

            if (solutionLoadDefaultDetail == null)
            {
                throw new PowerDesignProException("LoadNotFound", Message.SolutionLoad);
            }

            var voltageFrequencyDetail = _solutionSetupRepository.GetAll(x => x.SolutionID == searchMotorLoadDto.SolutionID)
                                         .Select(r =>
                                                 new
            {
                r.VoltagePhaseID,
                r.VoltageNominalID,
                r.VoltageSpecificID,
                r.FrequencyID,
                r.Frequency.Value
            }).FirstOrDefault();

            solutionLoadDefaultDetail.ID = 0;
            if (searchMotorLoadDto.ID != 0)
            {
                var motorLoadDetail = _motorLoadRepository.GetSingle(x => x.ID == searchMotorLoadDto.ID);

                if (motorLoadDetail == null)
                {
                    throw new PowerDesignProException("MotorLoadNotFound", Message.SolutionLoad);
                }

                var result = _motorLoadEntityToMotorLoadDtoMapper.AddMap(motorLoadDetail, userName: userName);
                result.Frequency = Convert.ToInt32(voltageFrequencyDetail.Value);
                result.StartingMethodEditable     = solutionLoadDefaultDetail.StartingMethodEditable;
                result.ConfigurationInputEditable = solutionLoadDefaultDetail.ConfigurationInputEditable;
                result.MotorLoadLevelEditable     = solutionLoadDefaultDetail.MotorLoadLevelEditable;
                result.MotorLoadTypeEditable      = solutionLoadDefaultDetail.MotorLoadTypeEditable;
                result.MotorTypeEditable          = solutionLoadDefaultDetail.MotorTypeEditable;
                result.StartingCodeEditable       = solutionLoadDefaultDetail.StartingCodeEditable;
                result.SizeRunningEditable        = solutionLoadDefaultDetail.SizeRunningEditable;
                result.HarmonicTypeEditable       = solutionLoadDefaultDetail.HarmonicTypeEditable;

                result.FrequencyID = voltageFrequencyDetail.FrequencyID;
                return(result);
            }
            else
            {
                var result = _loadDefaultsEntityToMotorLoadDtoMapper.AddMap(solutionLoadDefaultDetail);
                if (result != null)
                {
                    var countLoad = _motorLoadRepository.GetAll(x => x.LoadID == solutionLoadDefaultDetail.LoadID && x.SolutionID == searchMotorLoadDto.SolutionID).Count();
                    result.Description = string.Concat(solutionLoadDefaultDetail.Load.Description, " #", countLoad + 1);

                    var voltageNominalSpecificLoads = GetVoltageNominalSpecificForLoads(voltageFrequencyDetail.VoltageNominalID, voltageFrequencyDetail.VoltageSpecificID, voltageFrequencyDetail.VoltagePhaseID,
                                                                                        voltageFrequencyDetail.FrequencyID);

                    result.VoltagePhaseID    = voltageFrequencyDetail.VoltagePhaseID;
                    result.VoltageNominalID  = voltageNominalSpecificLoads.VoltageNominalID;
                    result.VoltageSpecificID = voltageNominalSpecificLoads.VoltageSpecificID;
                    result.Frequency         = Convert.ToInt32(voltageFrequencyDetail.Value);
                    result.FrequencyID       = voltageFrequencyDetail.FrequencyID;
                    result.HarmonicContentID = solutionLoadDefaultDetail.HarmonicDeviceType.HarmonicContentID;
                    result.StartingMethodID  = solutionLoadDefaultDetail.StartingMethodID;

                    return(result);
                }
            }

            return(new MotorLoadDto());
        }
Esempio n. 13
0
        private SharedProjectsDto AddSharedProjects(SharedProjectsDto sharedProjectsDto, string userID, string userName)
        {
            try
            {
                SharedProject sharedProjectDetails;
                SharedProject sharedProject = _sharedProjectsRepository.GetSingle(s => s.ProjectID == sharedProjectsDto.ProjectID && s.RecipientEmail.Equals(sharedProjectsDto.RecipientEmail, StringComparison.InvariantCultureIgnoreCase));
                if (sharedProject != null)
                {
                    foreach (var sharedSolutionID in sharedProjectsDto.SelectedSolutionList)
                    {
                        if (sharedProject.SharedProjectSolution.Where(s => s.SharedProjectID == sharedProject.ID && s.SolutionID == sharedSolutionID).Count() <= 0)
                        {
                            sharedProject.SharedProjectSolution.Add(new SharedProjectSolution
                            {
                                SharedProjectID  = sharedProject.ID,
                                SolutionID       = sharedSolutionID,
                                CreatedDateTime  = DateTime.UtcNow,
                                SharedDateTime   = DateTime.UtcNow,
                                ModifiedDateTime = DateTime.UtcNow,
                                CreatedBy        = userName,
                                ModifiedBy       = userName,
                                Active           = true
                            });
                        }
                        //else
                        //{
                        //    sharedProject.SharedProjectSolution.Remove(_sharedProjectSolutionRespository.GetSingle(s => s.SolutionID == sharedSolutionID));
                        //}
                    }
                    _sharedProjectsEntityToSharedProjectsDtoMapper.UpdateMap(sharedProjectsDto, sharedProject, userID);
                    sharedProject.ModifiedDateTime = DateTime.UtcNow;
                    sharedProject.ModifiedBy       = userName;
                    sharedProject.Active           = true;

                    sharedProjectDetails = _sharedProjectsRepository.Update(sharedProject);
                    _sharedProjectsRepository.Commit();
                }
                else
                {
                    sharedProject = _sharedProjectsEntityToSharedProjectsDtoMapper.AddMap(sharedProjectsDto, userID);
                    sharedProject.CreatedDateTime  = DateTime.UtcNow;
                    sharedProject.CreatedBy        = userName;
                    sharedProject.SharedDateTime   = DateTime.UtcNow;
                    sharedProject.ModifiedDateTime = DateTime.UtcNow;
                    sharedProject.ModifiedBy       = userName;
                    sharedProject.Active           = true;

                    sharedProject.SharedProjectSolution = sharedProjectsDto.SelectedSolutionList.Select(solutionID => new SharedProjectSolution
                    {
                        SolutionID       = solutionID,
                        CreatedDateTime  = DateTime.UtcNow,
                        SharedDateTime   = DateTime.UtcNow,
                        ModifiedDateTime = DateTime.UtcNow,
                        CreatedBy        = userName,
                        ModifiedBy       = userName,
                        Active           = true
                    }).ToList();

                    sharedProjectDetails = _sharedProjectsRepository.Add(sharedProject);
                    _sharedProjectsRepository.Commit();
                }

                Project sharedProjectRow  = _projectRepository.GetSingle(p => p.ID == sharedProjectsDto.ProjectID);
                var     sharedProjectName = sharedProjectRow.ProjectName;
                var     sharerUserName    = sharedProjectRow.User.FirstName + " " + sharedProjectRow.User.LastName;

                return(new SharedProjectsDto
                {
                    SharedProjectID = sharedProjectDetails.ID,
                    SharedProjectName = sharedProjectName,
                    SharerUserName = sharerUserName
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 14
0
 public IEnumerable <PickListDto> GetSearchFilter()
 {
     return(_searchFilterRepository.GetAll().OrderBy(x => x.Ordinal).ToList().
            Select(x => _pickListEntityToDtoMapper.AddMap(x)).ToList());
 }
Esempio n. 15
0
 public IEnumerable <HarmonicDeviceTypeDto> GetHarmonicDeviceType()
 {
     return(_harmonicDeviceTypeRepository.GetAll(x => x.Active).OrderBy(x => x.Ordinal).ToList().
            Select(x => _harmonicDeviceTypeEntityToDtoMapper.AddMap(x)).ToList());
 }
Esempio n. 16
0
 public IEnumerable <StatePickListDto> GetState()
 {
     return(_stateRepository.GetAll().OrderBy(x => x.Description).ToList().
            Select(x => _statePickListEntityToDtoMapper.AddMap(x)).ToList());
 }
Esempio n. 17
0
 /// <summary>
 /// Gets the voltage specific.
 /// </summary>
 /// <returns></returns>
 public IEnumerable <VoltageSpecificDto> GetVoltageSpecific()
 {
     return(_voltageSpecificRepository.GetAll().OrderBy(x => x.Ordinal).ToList().
            Select(x => _voltageSpecificEntityToDtoMapper.AddMap(x)).ToList());
 }
Esempio n. 18
0
 /// <summary>
 /// Gets the voltage nominal.
 /// </summary>
 /// <returns></returns>
 public IEnumerable <VoltageNominalDto> GetVoltageNominal(bool IsForLoads)
 {
     return(_voltageNominalRepository.GetAll(vn => vn.IsForLoads == IsForLoads).OrderBy(x => x.Ordinal).ToList().
            Select(x => _voltageNominalEntityToDtoMapper.AddMap(x)).ToList());
 }