示例#1
0
 public List <sp_GetMessages_Result> GetNotifications(DateTime afterDate, string username)
 {
     using (XSkillsEntities1 dc = new XSkillsEntities1())
     {
         return(dc.sp_GetMessages(commentID: 0, username: username).Where(a => a.CommentDate > afterDate).OrderByDescending(a => a.CommentDate).ToList());
     }
 }
示例#2
0
        public ActionResult EditProfile(EditProfileModel model, HttpPostedFileBase postedFile)
        {
            //string username = (string)TempData["UserName"];
            if (postedFile != null)
            {
                string fileName = Path.GetFileName(postedFile.FileName);
                string path     = Server.MapPath("~/UploadedFiles/Images/profiles/");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                postedFile.SaveAs(path + fileName);
                ViewBag.ImageUrl = "~/UploadedFiles/Images/profiles/" + fileName;
            }

            using (XSkillsEntities1 entities = new XSkillsEntities1())
            {
                User_Profile xmodel = entities.User_Profile.Where(x => x.Name == model.Name).FirstOrDefault();
                //xmodel.Name = model.Name;
                xmodel.Skills              = model.Skills;
                xmodel.Wave                = model.Wave;
                xmodel.Trainings           = model.Trainings;
                xmodel.Certifications      = model.Certifications;
                xmodel.ImgUrl              = ViewBag.ImageUrl == null ? model.ImgUrl : ViewBag.ImageUrl;
                xmodel.Aspirational_Skills = string.Join(",", model.AspirationSkillsIds);

                model.ImgUrl = ViewBag.ImageUrl == null ? model.ImgUrl : ViewBag.ImageUrl;

                entities.SaveChanges();
            }
            model.AspirationSkills = GetItems(model.Aspirational_Skills, "Skills");
            return(View(model));
        }
        private static TeamMembersModel PopulateModel(string skill)
        {
            using (XSkillsEntities1 entities = new XSkillsEntities1())
            {
                TeamMembersModel model = new TeamMembersModel()
                {
                    Members = (from c in entities.User_Profile
                               where c.Skills.Contains(skill) || string.IsNullOrEmpty(skill)
                               select c).ToList(),
                    Skills = (from c in entities.User_Profile
                              select new SelectListItem {
                        Text = c.Skills, Value = c.Skills
                    }).Distinct().ToList()
                };

                return(model);
            }
        }
示例#4
0
 public ActionResult RateUs(RatingModel rating)
 {
     if (ModelState.IsValid)
     {
         using (XSkillsEntities1 entities = new XSkillsEntities1())
         {
             Rating rate = new Rating()
             {
                 Userid   = User.Identity.Name,
                 Rating1  = rating.RatingNo,
                 Feedback = rating.Feedback
             };
             entities.Ratings.Add(rate);
             entities.SaveChanges();
         }
     }
     return(View());
 }
        public JsonResult displaySuggestions(string value)
        {
            string userid   = User.Identity.Name;
            var    username = dbContext.Users.Where(x => x.Email == userid).FirstOrDefault().Name;

            if (value == "N")
            {
                var user_profile = context.User_Profile.Where(x => x.Name == username).FirstOrDefault();
                var _user        = new User_Profile()
                {
                    Name = user_profile.Name, Wave = user_profile.Wave, Suggestions = value
                };

                using (var newContext = new XSkillsEntities1())
                {
                    newContext.User_Profile.Attach(_user);
                    newContext.Entry(_user).Property(X => X.Suggestions).IsModified = true;
                    newContext.SaveChanges();
                }
            }
            return(Json(new { error = false }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult SharePostSubmit(PostsModel posts)
        {
            string userid   = User.Identity.Name;
            string username = dbContext.Users.Where(x => x.Email == userid).FirstOrDefault().Name;

            if (!ModelState.IsValid)
            {
                var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors);
                var message          = "Please fix the following: " + Environment.NewLine;

                foreach (var modelStateError in modelStateErrors)
                {
                    message += modelStateError.ErrorMessage + Environment.NewLine;
                }

                return(Json(new { success = false, response = message }));
            }
            if (ModelState.IsValid)
            {
                string        isAttached       = "N";
                List <string> attachment_url   = new List <string>();
                List <string> attachement_type = new List <string>();

                if (posts.attachedfile != null)
                {
                    foreach (HttpPostedFileBase file in posts.attachedfile)
                    {
                        string fileName = Path.GetFileName(file.FileName);
                        string path     = Server.MapPath("~/UploadedFiles/");
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }

                        file.SaveAs(path + fileName);

                        isAttached = "Y";
                        attachment_url.Add("\\UploadedFiles\\" + fileName);
                        attachement_type.Add(file.ContentType);
                    }
                }
                if (posts.attachedaudio != null)
                {
                    foreach (HttpPostedFileBase file in posts.attachedaudio)
                    {
                        string fileName = Path.GetFileName(file.FileName);
                        string path     = Server.MapPath("~/UploadedFiles/");
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }

                        file.SaveAs(path + fileName);

                        isAttached = "Y";
                        attachment_url.Add("\\UploadedFiles\\" + fileName);
                        attachement_type.Add(file.ContentType);
                    }
                }
                if (posts.attachedimages != null)
                {
                    foreach (HttpPostedFileBase file in posts.attachedimages)
                    {
                        string fileName = Path.GetFileName(file.FileName);
                        string path     = Server.MapPath("~/UploadedFiles/");
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }

                        file.SaveAs(path + fileName);

                        isAttached = "Y";
                        attachment_url.Add("\\UploadedFiles\\" + fileName);
                        attachement_type.Add(file.ContentType);
                    }
                }
                if (posts.attachedvideos != null)
                {
                    foreach (HttpPostedFileBase file in posts.attachedvideos)
                    {
                        string fileName = Path.GetFileName(file.FileName);
                        string path     = Server.MapPath("~/UploadedFiles/");
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }

                        file.SaveAs(path + fileName);

                        isAttached = "Y";
                        attachment_url.Add("\\UploadedFiles\\" + fileName);
                        attachement_type.Add(file.ContentType);
                    }
                }

                using (XSkillsEntities1 entities = new XSkillsEntities1())
                {
                    Post post = new Post()
                    {
                        UserId          = userid,
                        Section_Type    = posts.Section_Type,
                        Message         = posts.Message,
                        Attachment      = isAttached,
                        Attachment_URL  = string.Join(";", attachment_url),
                        Attachment_Type = string.Join(";", attachement_type),
                        Skills          = posts.Skills,
                        CreatedDate     = DateTime.Now,
                        UserName        = username
                    };
                    entities.Posts.Add(post);
                    entities.SaveChanges();
                }
                //return RedirectToAction("Index");
                return(Json(new { success = true, url = Url.Action("Index", "KnowledgeHub") }));
            }
            //return RedirectToAction("Index");
            ViewBag.Skills         = Getitems("Skills");
            ViewBag.PersonalSkills = Getitems("PersonalSkills");
            return(Json(new { success = true, error = "Error" }));
        }