public ActionResult AddTechnology(TechnologyModel newTechnologyModel)
        {
            TechnologyEntity newTechnologyEntity = manage.ConvertTechnologyModelToEntity(newTechnologyModel);

            accessBusinessLayer.AddTechnology(newTechnologyEntity);
            return(View("Index"));
        }
Exemplo n.º 2
0
        public IActionResult Add(TechnologyEntity technology, string StatusRemarks, bool isSubcategoryInQuery)
        {
            int    errorCode = 0;
            string nextID    = "";

            try
            {
                nextID = SequenceHelper.GetNextSequence(Constants.ID, Constants.TABLE_TECHNOLOGY, Constants.PADDING_TECHNOLOGYID);

                technology.RowKey = technology.RowKey + "_" + nextID;

                technology.Description = technology.Description ?? "";

                technology.Tag = InsertTag(technology.NewTag, technology.Tag);

                DuplicateCheckEntity duplicateCheck = new DuplicateCheckEntity(technology.PartitionKey, technology.SubcategoryID + "_" + technology.NameHash);

                TechnologyStatusEntity technologyStatus = GetTechnologyStatusEntity(technology.PartitionKey, nextID, technology.Status, StatusRemarks);

                TableStorageHelper.InsertBatchAsync(Constants.TABLE_TECHNOLOGY, duplicateCheck, technology, technologyStatus).Wait();
            }
            catch (Exception ex)
            {
                nextID = "";
                if (!TableStorageHelper.IsStorageException(ex, out errorCode))
                {
                    errorCode = Constants.ERROR_CODE_COMMON;
                }
            }

            return(RedirectToAction("Index", new { errorCode = errorCode, category = technology.PartitionKey, subcategory = ((isSubcategoryInQuery) ? technology.SubcategoryID : ""), technology = nextID }));
        }
Exemplo n.º 3
0
        public IActionResult Edit(TechnologyEntity technology, string OriginalNameHash, bool isSubcategoryInQuery)
        {
            int errorCode = 0;

            try
            {
                technology.Description = technology.Description ?? "";

                technology.Tag = InsertTag(technology.NewTag, technology.Tag);

                if (OriginalNameHash.Equals(technology.NameHash))
                {
                    TableStorageHelper.MergeAsync(Constants.TABLE_TECHNOLOGY, technology).Wait();
                }
                else
                {
                    DuplicateCheckEntity duplicateCheckOriginalDelete = new DuplicateCheckEntity(technology.PartitionKey, technology.SubcategoryID + "_" + OriginalNameHash);
                    duplicateCheckOriginalDelete.ETag = "*";

                    DuplicateCheckEntity duplicateCheckNewAdd = new DuplicateCheckEntity(technology.PartitionKey, technology.SubcategoryID + "_" + technology.NameHash);

                    TableStorageHelper.BatchAsync(Constants.TABLE_TECHNOLOGY, new DuplicateCheckEntity[] { duplicateCheckOriginalDelete }, new DuplicateCheckEntity[] { duplicateCheckNewAdd }, new TechnologyEntity[] { technology }).Wait();
                }
            }
            catch (Exception ex)
            {
                if (!TableStorageHelper.IsStorageException(ex, out errorCode))
                {
                    errorCode = Constants.ERROR_CODE_COMMON;
                }
            }

            return(RedirectToAction("Index", new { errorCode = errorCode, category = technology.PartitionKey, subcategory = ((isSubcategoryInQuery) ? technology.SubcategoryID : ""), technology = technology.ID }));
        }
        public List <CandidateEntity> GetAllCandidates()
        {
            List <CandidateEntity> Candidates = new List <CandidateEntity>();
            SqlConnection          connection = new SqlConnection("Data Source=DESKTOP-OTH8BE1;Initial Catalog=CampusMind;Integrated Security=True");

            connection.Open();
            string sqlQuery = string.Format("select * from Candidates");

            SqlCommand command = new SqlCommand(sqlQuery, connection);

            SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
            DataTable      table       = new DataTable();

            dataAdapter.Fill(table);
            connection.Close();

            foreach (DataRow item in table.Rows)
            {
                TechnologyEntity technology = new TechnologyEntity();
                CandidateEntity  candidate  = new CandidateEntity();
                candidate.CandidateId   = Convert.ToInt32(item["CandidateId"]);
                candidate.TechnologyId  = Convert.ToInt32(item["TechnologyId"]);
                candidate.CandidateName = Convert.ToString(item["CandidateName"]);
                candidate.LeadId        = Convert.ToInt32(item["LeadId"]);
                Candidates.Add(candidate);
            }
            return(Candidates);
        }
Exemplo n.º 5
0
 public User(IMessageQueue messageQueue)
 {
     _userStorage      = new UserEntity();
     _techStorage      = new TechnologyEntity();
     _projectStorage   = new ProjectEntity();
     _mapper           = new InitializeMapper().GetMapper;
     _pubJobsQueueName = AppSettings.PubJobsQueueName;
     _messageQueue     = messageQueue;
 }
Exemplo n.º 6
0
        public void CreateTechnoloy(Technology technology)
        {
            var technologyEntity = new TechnologyEntity {
                Description = technology.Description, Id = new Guid(), Title = technology.Title, Url = technology.Url
            };

            _context.Add(technologyEntity);

            _context.SaveChanges();
        }
Exemplo n.º 7
0
        private async Task ProcessReactionRemovedEvent(SlackEventFullDto <ReactionEventDto> slackEventDto)
        {
            if (InvalidTechnologyReaction(slackEventDto))
            {
                return;
            }

            string          reactionName = slackEventDto.Event.Reaction;
            SlackMessageDto messageDto   = await _slackService.ChatRetrieveMessage(slackEventDto.Event.Item.Channel, slackEventDto.Event.Item.Ts);

            MessageDetailsDto initialMessage = messageDto.Messages.First();
            Reaction          reaction       = initialMessage.Reactions?.Find(r => r.Name == reactionName);

            // Only delete technology if it's the last
            // instance of the particular reaction and
            // if the remaining reactions do not belong
            // to privileged members.
            if (reaction != null)
            {
                bool reactedByPrivilegedUsers = reaction.Users.Intersect(_privilegedMembers.Members).Count() > 0;
                bool reactedByOwner           = reaction.Users.Contains(initialMessage.User);

                if (reactedByPrivilegedUsers || reactedByOwner)
                {
                    return;
                }
            }

            string technologyName = reactionName.Remove(reactionName.LastIndexOf("-"));

            // if technology name uses keywords - replace them with appropriate
            // value
            foreach (var word in _keywords)
            {
                technologyName = technologyName.Replace(word.Key, word.Value);
            }

            string     workspaceId       = slackEventDto.TeamId;
            string     workspaceMemberId = slackEventDto.Event.ItemUser;
            UserEntity user = await GetUserEntity(workspaceId, workspaceMemberId);

            TechnologyEntity technology = user.UserTechnologies.Find(tech => tech.Name == technologyName);

            // if technology has been deleted that for
            // some reason doesn't exist in db return
            if (technology == null)
            {
                return;
            }
            await _technologiesStorage.DeleteAsync(technology.Id);
        }
        public int AddTechnology(TechnologyEntity newTechnology)
        {
            // Serialization
            IFormatter format       = new BinaryFormatter();
            Stream     serializeObj = new FileStream(@"C:\Users\Sangee\Desktop\FILES\campusMind.txt", FileMode.Create, FileAccess.Write);

            format.Serialize(serializeObj, newTechnology);
            serializeObj.Close();

            // Deserialization
            Stream           desearlizeObj = new FileStream(@"C:\Users\Sangee\Desktop\FILES\campusMind.txt", FileMode.Open, FileAccess.Read);
            TechnologyEntity technology    = (TechnologyEntity)format.Deserialize(desearlizeObj);

            return(accessDataAcessLayer.AddTechnology(newTechnology));
        }
        public int AddTechnology(TechnologyEntity newTechnology)
        {
            string strConString = "Data Source=DESKTOP-OTH8BE1;Initial Catalog=CampusMind;Integrated Security=True";

            using (SqlConnection con = new SqlConnection(strConString))
            {
                con.Open();
                string     query = "Insert into Technologies(TechnologyName,Description) values(@Name, @description)";
                SqlCommand cmd   = new SqlCommand(query, con);
                cmd.Parameters.AddWithValue("@Name", newTechnology.TechnologyName);
                cmd.Parameters.AddWithValue("@description", newTechnology.Description);
                cmd.ExecuteNonQuery();
            }
            return(0);
        }
Exemplo n.º 10
0
        private List <TechnologyEntity> MapTechnologies(List <UserTechnologyDto> technologyDtos)
        {
            List <TechnologyEntity> technologies = new List <TechnologyEntity>();

            foreach (var technologyDto in technologyDtos)
            {
                TechnologyEntity techEntity = new TechnologyEntity()
                {
                    UserId    = technologyDto.UserId,
                    Name      = technologyDto.Name,
                    CreatedAt = DateTimeOffset.UtcNow,
                    UpdatedAt = DateTimeOffset.UtcNow
                };

                technologies.Add(techEntity);
            }
            return(technologies);
        }
Exemplo n.º 11
0
 public EventHandler(IConfiguration configuration)
 {
     _introductionChannelId        = configuration["IntroductionChannelId"];
     _privateIntroChannelId        = configuration["PrivateIntroChannelId"];
     _privateRegistrationChannelId = configuration["PrivateRegistrationChannelId"];
     _privateProjectsChannelId     = configuration["PrivateProjectsChannelId"];
     _projectIdeasChannel          = configuration["ProjectIdeasChannelId"];
     _chatAppUserStorage           = new ChatAppUserEntity();
     _technologiesStorage          = new TechnologyEntity();
     _slackService      = new SlackService();
     _passwordHasher    = new PasswordHasher <User>();
     _mapper            = new InitializeMapper().GetMapper;
     _privilegedMembers = JsonConvert.DeserializeObject <PrivilegedMembersDto>(configuration["PrivilegedMembers"]);
     _mainUrl           = configuration["MainUrl"];
     _keywords          = new Dictionary <string, string>()
     {
         { "dot", "." }, { "sharp", "#" }
     };
 }
Exemplo n.º 12
0
        private async Task ProcessReactionIntroAddedEvent(SlackEventFullDto <ReactionEventDto> slackEventDto)
        {
            if (InvalidTechnologyReaction(slackEventDto))
            {
                return;
            }

            // get technology from reaction and persist
            string reaction       = slackEventDto.Event.Reaction;
            string technologyName = reaction.Remove(reaction.LastIndexOf("-"));

            // if technology name uses keywords - replace them with appropriate
            // value
            foreach (var word in _keywords)
            {
                technologyName = technologyName.Replace(word.Key, word.Value);
            }

            string     workspaceId       = slackEventDto.TeamId;
            string     workspaceMemberId = slackEventDto.Event.ItemUser;
            UserEntity user = await GetUserEntity(workspaceId, workspaceMemberId);

            TechnologyEntity technology = new TechnologyEntity()
            {
                Name   = technologyName,
                UserId = user.Id
            };

            TechnologyEntity technologyExists = user.UserTechnologies.Find(t => t.Name == technologyName);

            // avoid duplicate entries by checking if
            // technology already exists in db
            if (technologyExists != null)
            {
                return;
            }

            // TODO: Replace with call to update user so that collab
            // suggestions are generated.
            await _technologiesStorage.CreateAsync(technology);

            return;
        }
Exemplo n.º 13
0
        public IList <ProjectTechnologyJunctionEntity> Resolve
        (
            TechnologyDto technologyDto,
            TechnologyEntity technologyEntity,
            IList <ProjectTechnologyJunctionEntity> destMember,
            ResolutionContext context
        )
        {
            var projects = new List <ProjectTechnologyJunctionEntity>();

            foreach (var project in technologyDto.Projects)
            {
                Func <DbSet <ProjectEntity>, Task <ProjectEntity> > projectRetrievalFunc =
                    dbSet => dbSet
                    .Include(proj => proj.ProjectType)
                    .Include(proj => proj.Technologies)
                    .ThenInclude(techs => techs.Technology)
                    .ThenInclude(tech => tech.TechnologyType)
                    .SingleAsync(proj => proj.Name == project.Name);

                Func <DbSet <TechnologyEntity>, Task <TechnologyEntity> > technologyRetrievalFunc =
                    dbSet => dbSet.Include(tech => tech.TechnologyType)
                    .Include(tech => tech.Projects)
                    .ThenInclude(projs => projs.Project)
                    .ThenInclude(proj => proj.ProjectType)
                    .SingleAsync(tech => tech.Name == technologyDto.Name);

                var retrievedProject    = DatabaseAccess.RetrieveEntityAsync(projectRetrievalFunc, ProjectEntitySet);
                var retrievedTechnology = DatabaseAccess.RetrieveEntityAsync(technologyRetrievalFunc, TechnologyEntitySet);

                var projectTechnologyJunctionEntity = new ProjectTechnologyJunctionEntity();
                projectTechnologyJunctionEntity.Project    = retrievedProject.Result;
                projectTechnologyJunctionEntity.Technology = retrievedTechnology.Result;

                projects.Add(projectTechnologyJunctionEntity);
            }

            return(projects);
        }
Exemplo n.º 14
0
        public IActionResult UpdateStatus(TechnologyEntity technology, string StatusRemarks, bool isSubcategoryInQuery)
        {
            int errorCode = 0;

            try
            {
                technology.Description = technology.Description ?? "";

                TechnologyStatusEntity technologyStatus = GetTechnologyStatusEntity(technology.PartitionKey, technology.ID, technology.Status, StatusRemarks);

                TableStorageHelper.BatchAsync(Constants.TABLE_TECHNOLOGY, null, new TechnologyStatusEntity[] { technologyStatus }, new TechnologyEntity[] { technology }).Wait();
            }
            catch (Exception ex)
            {
                if (!TableStorageHelper.IsStorageException(ex, out errorCode))
                {
                    errorCode = Constants.ERROR_CODE_COMMON;
                }
            }

            return(RedirectToAction("Index", new { errorCode = errorCode, category = technology.PartitionKey, subcategory = ((isSubcategoryInQuery) ? technology.SubcategoryID : ""), technology = technology.ID }));
        }
Exemplo n.º 15
0
 public void UpdateTechnoloy(TechnologyEntity technology)
 {
     _context.SaveChanges();
 }
Exemplo n.º 16
0
 public CollaboratorSuggestionsHandler()
 {
     _technologyStorage = new TechnologyEntity();
     _projectCollaboratorSuggestionsStorage = new ProjectCollaboratorSuggestionEntity();
 }