예제 #1
0
 public ActionResult AutocompleteTags(int limit)
 {
     TagManager tm = new TagManager();
     List<sTag> stags = new List<sTag>();
     stags = tm.GetAllSTags();
     List<string> tags = new List<string>();
     foreach (sTag s in stags)
     {
         tags.Add(s.value);
     }
     return Json(tags, JsonRequestBehavior.AllowGet);
 }
예제 #2
0
        private void FillFreeLancerTags()
        {
            TagManager tagManager = new TagManager();
            TagAccessor tagAccessor = new TagAccessor();

            string lines = (Resource.freelancer_tags);
            char[] separators = { '\n', '\r' };
            var etfs = lines.Split(separators, StringSplitOptions.RemoveEmptyEntries);
            int x = 0;
            do
            {
                if (x == etfs.Length)
                {
                    break;
                }
                if (etfs[x].Substring(0, 1) == "~")
                {
                    sTag top = tagManager.CreateSTag(0, etfs[x].Substring(1, etfs[x].Length - 1).Trim());
                    x++;
                    if (x == etfs.Length)
                    {
                        break;
                    }
                    while (etfs[x] != "!")
                    {
                        int i = etfs[x].IndexOf("(");
                        string value = etfs[x].Substring(0, i - 2);
                        sTag mid = tagManager.CreateSTag(tagAccessor.GetSTag(top.value).id, value);
                        x++;
                        if (x == etfs.Length)
                        {
                            break;
                        }
                    }
                }
                if (x == etfs.Length)
                {
                    break;
                }
                else if (etfs[x].Substring(0, 1) == "!")
                {
                    x++;
                    if (x == etfs.Length)
                    {
                        break;
                    }
                }
            }
            while (x < etfs.Length);
        }
        public ActionResult Profile(string profileURL)
        {
            if (profileURL == "")
            {
                User currentUser = userManager.GetUser(User.Identity.Name);
                return RedirectToAction("Profile", "User", new { profileURL = currentUser.profileURL });
            }

            //throw (new ArgumentNullException());
            TempData["MessageBar"] = TempData["MessageBar"];
            TempData["Popup"] = TempData["Popup"];

            try
            {
                ViewBag.DisplayPicture = false;
                ViewBag.DisplayInfo = false;

                TagManager tagManager = new TagManager();

                User user = userManager.GetUserByProfileURL(profileURL);
                if (user == null)
                {
                    try
                    {
                        string userNameLoggedIn = User.Identity.Name;
                        if (userNameLoggedIn == null || userNameLoggedIn == "")
                        {
                            return RedirectToAction("Index", "Home");
                        }
                        else
                        {
                            user = userManager.GetUser(userNameLoggedIn);
                        }
                    }
                    catch (Exception e)
                    {

                    }
                }
                else if ((User.Identity.Name != user.userName) && (user.isPublic != 1))
                {
                    //if not the owner and trying to access a user that is not public
                    return RedirectToAction("Index", "Home");
                }
                //else...
                //projectManager.moveProjectRight(user, 2);
                //userManager.UpdateUser(user);
                if (user.projectOrder == null)
                {
                    userManager.ResetProjectOrder(user);
                    userManager.UpdateUser(user);
                    foreach (Project p in user.projects)
                    {
                        projectManager.resetProjectElementOrder(p);
                        projectManager.UpdateProject(p);
                    }
                }

                ProfileModel model = new ProfileModel(user);
                List<string> tagValues = new List<string>();
                //Put user's tags on the ProfileModel
                /*
                if (user.tagIds != null && user.tagIds != "")
                {
                    List<Tag> tagList = tagManager.GetTags(user.tagIds);
                    foreach (Tag tag in tagList)
                    {
                        tagValues.Add(tag.value);
                    }
                    model.tagValues = tagValues;
                }*/

                //ViewBag.WillingToRelocate = new List<string>(Enum.GetNames(typeof(WillingToRelocateType)));

                if (user.userName == User.Identity.Name && User.Identity.IsAuthenticated)
                {
                    AnalyticsAccessor aa = new AnalyticsAccessor();
                    aa.CreateAnalytic("Profile Page Hit: Logged in", DateTime.Now, user.userName);

                    //User is going to their own profile
                    ViewBag.IsOwner = true;
                    model.connections = new List<User>();
                    if (user.connections != null)
                    {
                        foreach (string userId in user.connections.Split(','))
                        {
                            if (userId.Trim() != "")
                            {
                                int userIdInt = Convert.ToInt32(userId);
                                User connection = userManager.GetUser(userIdInt);
                                model.connections.Add(connection);
                            }
                        }
                    }

                    /*//depreciated. can't use .CompleteProfilePrompt any more. will have to deal with tags some other way
                     * if (userManager.IsProfilePartiallyComplete(user))
                    {
                        //User has already entered some extra information on their profile
                        ViewBag.CompleteProfilePrompt = false;
                    }
                    else
                    {
                        //User has not updated any further info on their profile
                        //Get list of tags for picking out which ones we initially want on our profile
                        List<string> listOfLowestLevelTags = userManager.GetAllLowestLevelTagValues();
                        ViewBag.LowestLevelTags = listOfLowestLevelTags;
                        ViewBag.CompleteProfilePrompt = true;
                    }*/
                }
                else
                {
                    AnalyticsAccessor aa = new AnalyticsAccessor();
                    aa.CreateAnalytic("Profile Page Hit: Not Logged in", DateTime.Now, user.userName);

                    //User is visiting someone else's profile
                    ViewBag.IsOwner = false;
                }

                //------------------------------------------------------------
                return View(model);
            }
            catch (Exception ex)
            {
                logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), ex.ToString());
                return View("Error");
            }
        }
 public JsonResult AddUserTag(string value)
 {
     TagManager tm = new TagManager();
     string type;
     if (tm.GetAllSTagValues().Contains(value))
     {
         type = "s";
     }
     else
     {
         type = "f";
     }
     string result = tm.AddTag(value, type, userManager.GetUser(User.Identity.Name).id);
     if (result != null)
     {
         if (result == "Tag already added.")
         {
             return Json(new { tagStatus = "Tag already added" });
         }
         else
         {
             return Json(new { tagStatus = "Tag Added!" });
         }
     }
     else
     {
         return Json(new { Error = "Failed to add tag :(" });
     }
 }
예제 #5
0
 public ProjectModel(Project project)
 {
     this.id = project.id;
     this.information = new List<ProjectElement_Information>();
     this.documents = new List<ProjectElement_Document>();
     this.experience = new List<ProjectElement_Experience>();
     this.pictures = new List<ProjectElement_Picture>();
     this.videos = new List<ProjectElement_Video>();
     this.audio = new List<ProjectElement_Audio>();
     this.name = project.name;
     this.coverPicture = project.coverPicture;
     this.coverPictureThumbnail = project.coverPictureThumbnail;
     this.description = project.description;
     this.isActive = project.isActive;
     this.projectElementOrder = project.projectElementOrder;
     TagManager tm = new TagManager();
     this.projectTags = tm.getAllProjectTags(project.id);
     foreach(ProjectElement element in project.projectElements){
         if (element.GetType() == typeof(ProjectElement_Document))
         {
             this.documents.Add((ProjectElement_Document)element);
         }
         else if (element.GetType() == typeof(ProjectElement_Experience))
         {
             this.experience.Add((ProjectElement_Experience)element);
         }
         else if (element.GetType() == typeof(ProjectElement_Information))
         {
             this.information.Add((ProjectElement_Information)element);
         }
         else if (element.GetType() == typeof(ProjectElement_Picture))
         {
             this.pictures.Add((ProjectElement_Picture)element);
         }
         else if (element.GetType() == typeof(ProjectElement_Video))
         {
             this.videos.Add((ProjectElement_Video)element);
         }
         else if (element.GetType() == typeof(ProjectElement_Audio))
         {
             this.audio.Add((ProjectElement_Audio)element);
         }
     }
 }
예제 #6
0
        public ProfileModel(User user)
        {
            this.id = user.id;
            this.birthDate = user.birthDate;
            this.description = user.description;
            //this.status = user.status;
            this.graduationDate = user.graduationDate;
            this.email = user.email;
            this.firstName = user.firstName;
            this.lastName = user.lastName;
            this.title = user.title;
            this.location = user.location;
            this.major = user.major;
            this.phoneNumber = user.phoneNumber;
            this.school = user.organization;
            this.userName = user.userName;
            //this.willingToRelocate = user.willingToRelocate;
            this.profilePicture = user.profilePicture;
            this.profilePictureThumbnail = user.profilePictureThumbnail;
            this.aboutPicture = user.aboutPicture;
            this.aboutPictureThumbnail = user.aboutPictureThumbnail;
            this.projects = new List<ProjectModel>();
            this.profileURL = user.profileURL;
            this.projectOrder = user.projectOrder;
            TagManager tm = new TagManager();
            this.userTags = tm.getAllUserTags(this.id);
            if(user.projects != null)
            {
                foreach (Project project in user.projects)
                {
                    if (project.isActive)
                    {
                        this.projects.Add(new ProjectModel(project));
                    }
                }
            }

            this.resume = user.resume;
            this.emailVerified = user.emailVerified;
            this.isPublic = user.isPublic;
            this.isActive = user.isActive;
            //this.visibleProject = "project0";
        }
예제 #7
0
        public string AddProjectTag(string value, int projectId, string token = null)
        {
            if (Request.RequestType.Equals("OPTIONS", StringComparison.InvariantCultureIgnoreCase))  //This is a preflight request
            {
                return null;
            }
            else
            {
                try
                {
                    int userId;
                    if (token != null)
                    {
                        userId = authenticationEngine.authenticate(token);
                    }
                    else
                    {
                        return AddErrorHeader("An authentication token must be passed in", 2);
                    }

                    if (userId < 0)
                    {
                        return AddErrorHeader("User not authenticated, please log in!", 2);
                    }
                    User user = userManager.GetUser(userId);

                    Project project = projectManager.GetProject(projectId);
                    if (!projectManager.IsUserOwnerOfProject(projectId, user))
                    {
                        return AddErrorHeader("User not authorized to add a tag to this project", 3);
                    }
                    TagManager tm = new TagManager();
                    string type;
                    if (tm.GetAllSTagValues().Contains(value))
                    {
                        type = "s";
                    }
                    else
                    {
                        type = "f";
                    }
                    string result = tm.AddTag(value, type, projectId);
                    if (result != null)
                    {
                        if (result == "Tag already added.")
                        {
                            return AddErrorHeader("This tag already exists", 1);
                        }
                        else
                        {
                            activityManager.AddActivity(user.id, "Project Tag", "Added", project.id);
                            return AddSuccessHeader("Tag Added Successfully" , true);
                        }
                    }
                    else
                    {
                        return AddErrorHeader("Tag could not be added to Project", 1);
                    }
                }
                catch (Exception ex)
                {
                    logAccessor.CreateLog(DateTime.Now,"ProjectController - AddProjectTag", ex.StackTrace);
                    return AddErrorHeader("Something went wrong while adding this Project Tag", 1);
                }
            }
        }
예제 #8
0
        public string DeleteProjectTag(string value = null, int projectId = -1, string token = null)
        {
            if (Request.RequestType.Equals("OPTIONS", StringComparison.InvariantCultureIgnoreCase))  //This is a preflight request
            {
                return null;
            }
            else
            {
                try
                {
                    int userId;
                    if (token != null)
                    {
                        userId = authenticationEngine.authenticate(token);
                    }
                    else
                    {
                        return AddErrorHeader("An authentication token must be passed in", 2);
                    }

                    if (userId < 0)
                    {
                        return AddErrorHeader("User not authenticated, please log in!", 2);
                    }
                    User user = userManager.GetUser(userId);

                    Project project = projectManager.GetProject(projectId);
                    if (!projectManager.IsUserOwnerOfProject(projectId, user))
                    {
                        return AddErrorHeader("User not authorized to delete this project", 3);
                    }
                    TagManager tm = new TagManager();
                    bool result = false;
                    sTag stag = tm.GetSTag(value);
                    if (stag != null)
                    {
                        result = tm.RemoveProjectLink(stag.id, projectId, "s");
                    }
                    else
                    {
                        fTag ftag = tm.GetFTag(value);
                        if (ftag != null)
                        {
                            result = tm.RemoveProjectLink(ftag.id, projectId, "f");
                        }
                        else
                        {
                            return AddErrorHeader("Tag does not exist in database", 1);
                        }
                    }
                    if (result == true)
                    {
                        return AddSuccessHeader("Tag Removed from Project: " + projectId , true);
                    }
                    else
                    {
                        return AddErrorHeader("Tag could not be removed from the Project", 1);
                    }
                }
                catch (Exception ex)
                {
                    logAccessor.CreateLog(DateTime.Now, "ProjectController - AddProjectTag", ex.StackTrace);
                    return AddErrorHeader("Something went wrong while removing this Project Tag", 1);
                }
            }
        }