public ActionResult CreateProject(TotalLikesPostsCommentsModel Addproject) { var projectdata = Addproject.CreateNewProject; if (ModelState.IsValid) { if (projectdata.fileUpload != null) { string fileName = Path.GetFileNameWithoutExtension(projectdata.fileUpload.FileName); string extension = Path.GetExtension(projectdata.fileUpload.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; projectdata.FilePath = "~/AppFiles/ProjectFiles/" + fileName; projectdata.fileUpload.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/ProjectFiles/"), fileName)); } projectdata.CreatedBy = WebSecurity.CurrentUserName; projectdata.CreatedDate = DateTime.Now.ToShortDateString(); using (WorkFlowDbContext db = new WorkFlowDbContext()) { db.Projects.Add(projectdata); db.SaveChanges(); } } return(RedirectToAction("Index", "Home")); }
public ActionResult Register(UserRegister registerModel) { GetRolesForCurrentUsers(); if (ModelState.IsValid) { using (WorkFlowDbContext db = new WorkFlowDbContext()) { bool isUserExist = WebSecurity.UserExists(registerModel.UserName); if (isUserExist) { ModelState.AddModelError("UserName", "UserName already exist"); } else { registerModel.Account = registerModel.Role; WebSecurity.CreateUserAndAccount(registerModel.UserName, registerModel.Password, new { registerModel.Account, status = 1 }); Roles.AddUserToRole(registerModel.UserName, registerModel.Role); var userid = (db.Users.OrderByDescending(s => s.UserId).Select(s => s.UserId)).FirstOrDefault(); UsersDetail userModel = new UsersDetail(); userModel.UserId = userid; db.UsersDetails.Add(userModel); db.SaveChanges(); ViewBag.Message = "User Added"; } } } return(View()); }
public ActionResult LikePost(int PostId) { using (WorkFlowDbContext db = new WorkFlowDbContext()) { var isLike = db.PostLikes.Where(s => (s.PostLike1 == true && s.UserId == WebSecurity.CurrentUserId && s.PostId == PostId)); var isdisLike = db.PostLikes.Where(s => (s.PostLike1 == false && s.UserId == WebSecurity.CurrentUserId && s.PostId == PostId)); if (isdisLike.Count() > 0 && isLike.Count() == 0) { updateLikeDislikePost(db, PostId, true); } else if (isLike.Count() > 0) { return(Json(new { success = true, message = "You already like this post" }, JsonRequestBehavior.AllowGet)); } else { InsertRecord(db, PostId, true); int likescount = GetUpdatedLikeDisLikeCounts(PostId, db, true); return(Json(new { success = true, postLikeCount = likescount, postId = PostId }, JsonRequestBehavior.AllowGet)); } int likecount = GetUpdatedLikeDisLikeCounts(PostId, db, true); int Dislikecount = GetUpdatedLikeDisLikeCounts(PostId, db, false); //return RedirectToAction("ViewPost","Forum"); return(Json(new { success = true, postLikeCount = likecount, dislikecount = Dislikecount, postId = PostId }, JsonRequestBehavior.AllowGet)); } }
public ActionResult UserProfile(UserDetail UsersModel) { try { if (ModelState.IsValid) { var imageUpdate = ""; if (UsersModel.ImageUpload != null) { string fileName = Path.GetFileNameWithoutExtension(UsersModel.ImageUpload.FileName); string extension = Path.GetExtension(UsersModel.ImageUpload.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; UsersModel.ImagePath = "~/AppFiles/Images/" + fileName; UsersModel.ImageUpload.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/Images/"), fileName)); } else { using (WorkFlowDbContext db = new WorkFlowDbContext()) { imageUpdate = db.UsersDetails.Where(s => s.UserId == WebSecurity.CurrentUserId).Select(s => s.ImagePath).FirstOrDefault(); } } using (WorkFlowDbContext db = new WorkFlowDbContext()) { if (UsersModel.ImageUpload == null) { UsersModel.ImagePath = imageUpdate; } UsersModel.UserId = WebSecurity.CurrentUserId; UsersDetail ud = new UsersDetail(); ud.UserDetailId = UsersModel.UserDetailId; ud.UserId = UsersModel.UserId; ud.FirstName = UsersModel.FirstName; ud.LastName = UsersModel.LastName; ud.Email = UsersModel.Email; ud.Mobile = UsersModel.Mobile; ud.UserAddress = UsersModel.UserAddress; ud.About = UsersModel.About; ud.ImagePath = UsersModel.ImagePath; db.Entry(ud).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Your profile has been updated!"; } } else { return(View(UsersModel)); } return(View(UsersModel)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
private void updateLikeDislikePost(WorkFlowDbContext db, int PId, bool v) { var UpdateId = db.PostLikes.Where(x => (x.PostId == PId && x.UserId == WebSecurity.CurrentUserId)).FirstOrDefault(); UpdateId.PostLike1 = v; db.SaveChanges(); }
public ActionResult RequestPaperApprovel(Paper paperModel) { if (ModelState.IsValid) { if (paperModel.fileUpload != null) { string fileName = Path.GetFileNameWithoutExtension(paperModel.fileUpload.FileName); string extension = Path.GetExtension(paperModel.fileUpload.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; paperModel.FilePath = "~/AppFiles/Files/" + fileName; paperModel.fileUpload.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/Files/"), fileName)); } using (WorkFlowDbContext db = new WorkFlowDbContext()) { paperModel.UserId = WebSecurity.CurrentUserId; db.Papers.Add(paperModel); db.SaveChanges(); ViewBag.Message = "Data added"; return(RedirectToAction("PaperStatus", "Employee")); } } return(View()); }
public static NotificationViewModel UserNotifyList(WorkFlowDbContext db, int id) { var UserResult = db.UsersDetails.Where(s => s.UserId == id).FirstOrDefault(); var MeetingResult = db.Users.Join(db.Meetings, ud => ud.UserId, m => m.UserId, (ud, m) => new { Use = ud, meet = m }).Select(s => new MeetingModel { MeetingId = s.meet.MeetingId, UserId = s.meet.UserId, MeetingPoints = s.meet.MeetingPoints, MeetingTime = s.meet.MeetingTime, MeetingCreatedBy = s.meet.CreatedBy, IsViewd = s.meet.IsViewd, }).Where(s => s.UserId == id).OrderByDescending(s => s.MeetingId).Take(5).ToList(); var totalNotification = MeetingResult.Where(s => s.IsViewd != true).Count(); var UserNotifyList = new NotificationViewModel { userModel = UserResult, meetingModel = MeetingResult, totalCount = totalNotification }; return(UserNotifyList); }
private void GetRolesForCurrentUsers() { using (WorkFlowDbContext db = new WorkFlowDbContext()) { var item = new SelectList(db.webpages_Roles.Where(s => s.RoleName != "Principle").ToList(), "RoleName", "RoleName"); ViewData["Roles"] = item; } }
public UserController(WorkFlowDbContext context) { converter = new Converter(); um = new UserManagement(context); rm = new RoleManagement(context); es = new EmailSendingManagement(); pm = new ProjectManagement(context); }
private void GetTopicsForCurrentPost() { using (WorkFlowDbContext db = new WorkFlowDbContext()) { var item = new SelectList(db.Topics.ToList(), "TopicId", "TopicName"); ViewData["Topics"] = item; } }
// GET: Home public ActionResult Index() { obj.GetFiles(); WorkFlowDbContext db = new WorkFlowDbContext(); var fullNAme = new SelectList(db.UsersDetails.Where(s => s.UserId != WebSecurity.CurrentUserId).ToList(), "UserId", "FirstName"); ViewData["Users"] = fullNAme; return(View(GetTotalCommentsLikesAndPosts())); }
public ActionResult BlockComments(int CommentId) { using (WorkFlowDbContext db = new WorkFlowDbContext()) { var finddata = db.PostComments.Find(CommentId); finddata.Status = false; db.SaveChanges(); return(Json(new { status = true }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Completed(int id) { using (WorkFlowDbContext db = new WorkFlowDbContext()) { var verab = db.Projects.Find(id); verab.Status = true; db.SaveChanges(); } return(RedirectToAction("Index", "Employee")); }
private void GetTopicsForCurrentPost() { using (WorkFlowDbContext db = new WorkFlowDbContext()) { var item = new SelectList(db.Topics.ToList(), "TopicId", "TopicName"); ViewData["Topics"] = item; var fullNAme = new SelectList(db.UsersDetails.Where(s => s.UserId != WebSecurity.CurrentUserId).ToList(), "UserId", "FirstName"); ViewData["Users"] = fullNAme; } }
public ActionResult LeaveReject(Leaf leave, int id) { using (WorkFlowDbContext db = new WorkFlowDbContext()) { leave = db.Leaves.Find(id); leave.Status = false; db.Entry(db.Leaves.Where(x => x.LeaveId == id).FirstOrDefault()).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("AproveLeave", "Admin")); } }
public ActionResult PaperReject(Paper pap, int id) { using (WorkFlowDbContext db = new WorkFlowDbContext()) { pap = db.Papers.Find(id); pap.PaperStatus = false; db.Entry(db.Papers.Where(x => x.PaperId == id).FirstOrDefault()).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ApprovePaper", "Admin")); } }
public ActionResult GetUserDetailsAndNotifications() { int UserId = WebSecurity.CurrentUserId; using (WorkFlowDbContext db = new WorkFlowDbContext()) { NotificationViewModel NotifyMe = NotificationViewModel.UserNotifyList(db, UserId); ViewBag.count = NotifyMe.totalCount; return(PartialView("NavPartial", NotifyMe)); } }
private void InsertRecord(WorkFlowDbContext db, int likeId, bool status) { PostLike NewLikeDislike = new PostLike(); NewLikeDislike.PostId = likeId; NewLikeDislike.UserId = WebSecurity.CurrentUserId; NewLikeDislike.PostLike1 = status; db.PostLikes.Add(NewLikeDislike); db.SaveChanges(); }
// GET: Forum public ActionResult AddPost() { GetTopicsForCurrentPost(); using (WorkFlowDbContext db = new WorkFlowDbContext()) { var ListData = db.Topics.ToList(); var dispaly = new PostTopicViewModel { displayTopic = ListData }; return(View(dispaly)); } }
private TotalLikesPostsCommentsModel GetTotalCommentsLikesAndPosts() { using (WorkFlowDbContext db = new WorkFlowDbContext()) { TotalLikesPostsCommentsModel totaldata = TotalLikesPostsCommentsModel.GetRecord(db); ViewBag.TotalPosts = totaldata.totalPostList; ViewBag.TotalLikes = totaldata.totalLikesList; ViewBag.TotalComments = totaldata.totalCommentsList; ViewBag.TotalUsers = totaldata.totalUsersList; ViewBag.TotalCompletedProjects = totaldata.totalProjects; return(totaldata); } }
public ActionResult Login(UserLogin userLogin) { using (WorkFlowDbContext db = new WorkFlowDbContext()) { if (ModelState.IsValid) { var Isblock = db.Users.Where(x => (x.UserName == userLogin.UserName && x.Status == false)); bool isAthenciated = WebSecurity.Login(userLogin.UserName, userLogin.Password); if (isAthenciated) { if (Isblock.Count() == 0) { string returnUrl = Request.QueryString["ReturnUrl"]; var UserAccount = db.Users.Where(s => s.UserName == userLogin.UserName).Select(f => f.Account).FirstOrDefault(); if (returnUrl == null) { if (UserAccount == "Principle") { return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Index", "Employee")); } } else { if (UserAccount == "Principle") { return(Redirect(Url.Content(returnUrl))); } else { return(RedirectToAction("Index", "Employee")); } } } else { ModelState.AddModelError("", "Your Account is block by Admin"); } } else { ModelState.AddModelError("", "User Name or password is invalid"); } } } return(View()); }
public ActionResult RequestLeave(Leaf leav) { using (WorkFlowDbContext db = new WorkFlowDbContext()) { if (ModelState.IsValid) { leav.UserId = WebSecurity.CurrentUserId; db.Leaves.Add(leav); db.SaveChanges(); return(RedirectToAction("ViewLeaveStatus", "Employee")); } } return(View()); }
public ActionResult ViewPost() { WorkFlowDbContext db = new WorkFlowDbContext(); var posts = from p in db.Posts join u in db.UsersDetails on p.UserId equals u.UserId join a in db.Users on p.UserId equals a.UserId select new ShowPostViewModel { Post = p, FirstName = u.FirstName + " " + u.LastName, ImagePath = u.ImagePath, Account = a.Account }; return(View(posts.OrderByDescending(s => s.Post.PostId).ToList())); }
public ActionResult AddTopic(string TopicName) { if (TopicName != "") { using (WorkFlowDbContext db = new WorkFlowDbContext()) { Topic AddTopicData = new Topic(); AddTopicData.TopicName = TopicName; AddTopicData.CreatedBy = WebSecurity.CurrentUserName; db.Topics.Add(AddTopicData); db.SaveChanges(); return(Json(new { status = true }, JsonRequestBehavior.AllowGet)); } } return(Json(new { status = false }, JsonRequestBehavior.AllowGet)); }
// GET: Employee public ActionResult Index() { obj.GetFiles(); WorkFlowDbContext db = new WorkFlowDbContext(); var AdminId = db.Users.Where(s => s.Account == "Principle").Select(f => f.UserId).FirstOrDefault(); var fullNAme = new SelectList(db.UsersDetails.Where(s => (s.UserId != WebSecurity.CurrentUserId && s.UserId != AdminId)).ToList(), "UserId", "FirstName"); ViewData["Users"] = fullNAme; var ProjectName = new SelectList(db.Projects.Where(s => s.Status != true).ToList(), "ProjectId", "ProjectTitle"); ViewData["ProjectData"] = ProjectName; return(View(GetTotalCommentsLikesAndPosts())); }
public ActionResult CreateProject(EmployeeViewModel Addproject) { var projectdata = Addproject.CreateNewProject; if (ModelState.IsValid) { projectdata.AssignedBy = WebSecurity.CurrentUserName; projectdata.CreatedDate = DateTime.Now.ToShortDateString(); using (WorkFlowDbContext db = new WorkFlowDbContext()) { db.ProjectTasks.Add(projectdata); db.SaveChanges(); } } return(RedirectToAction("Index", "Employee")); }
public ActionResult AddPost(Post AddNewPost) { GetTopicsForCurrentPost(); if (ModelState.IsValid) { using (WorkFlowDbContext db = new WorkFlowDbContext()) { AddNewPost.UserId = WebSecurity.CurrentUserId; AddNewPost.CreatedTime = DateTime.Now.ToShortDateString(); AddNewPost.Status = true; db.Posts.Add(AddNewPost); db.SaveChanges(); return(Json(new { status = true }, JsonRequestBehavior.AllowGet)); } } return(Json(new { status = false }, JsonRequestBehavior.AllowGet)); }
public ActionResult UserProfile() { using (WorkFlowDbContext db = new WorkFlowDbContext()) { var data = db.UsersDetails.Where(x => x.UserId == WebSecurity.CurrentUserId).Select(s => new UserDetail { UserDetailId = s.UserDetailId, FirstName = s.FirstName, LastName = s.LastName, Email = s.Email, Mobile = s.Mobile, UserAddress = s.UserAddress, About = s.About, ImagePath = s.ImagePath }).FirstOrDefault(); return(View(data)); } }
public ActionResult Block(int id) { using (WorkFlowDbContext db = new WorkFlowDbContext()) { var Isblock = db.Users.Where(x => (x.UserId == id && x.Status == true)); User u = db.Users.Find(id); if (Isblock.Count() > 0) { updateUserStatus(id, db, u, false); } else { updateUserStatus(id, db, u, true); } } return(RedirectToAction("ManageFaculty", "Admin")); }
public void TestSelfRegisterUserAsync() { //Arrange IWorkFlowDbContext dbContext = new WorkFlowDbContext(); var fixture = new SelfRegistrationServiceFixture() .BuildSelfRegistrationServiceFixture() .BuildWorkFlowDbContextFactory(dbContext); SelfRegistrationDto selfRegistrationDto = null; //Act fixture.Service.SelfRegisterUserAsync(selfRegistrationDto); //Assert Mock.Get(fixture.dbFactory).Verify(f => f.CreateContext(), Times.AtLeastOnce); }