public ActionResult UserActivity(int?id) { List <User> userList = new List <User>(); userList = _db.GetAllUsersFromFamilyID(((User)Session["User"]).FamilyID); UserActivityViewModel model = new UserActivityViewModel(_db); model.UserList = userList; if (id.HasValue) { model.UserID = id.Value; //loading up the list of Prizes & Progress User user = _db.GetUserByID(model.UserID); model.PrizeList = _db.GetPrizesByUser(user); //loading active/inactive books model.ActiveBooks = _db.GetAllBooksByFamilyID(user.FamilyID); //model.InactiveBooks = _db.GetInactiveBooks(model.UserID); //loading reading log model.ReadingLogs = _db.GetReadingLog(model.UserID); } else { model.UserID = (Session["User"] as User).ID; //loading up the list of Prizes & Progress User user = _db.GetUserByID(model.UserID); model.PrizeList = _db.GetPrizesByUser(user); //Loading active/inactive books model.ActiveBooks = _db.GetAllBooksByFamilyID(user.FamilyID); //model.InactiveBooks = _db.GetInactiveBooks(model.UserID); //reading logs model.ReadingLogs = _db.GetReadingLog(model.UserID); } return(View("UserActivity", model)); }
public async Task <ActionResult> CustomerSetExecutorForIndent(UserActivityViewModel activityModel) { var clientId = Session["Id"]; if (clientId == null) { return(RedirectToAction("Registration", "Customer")); } int customerId = Convert.ToInt32(clientId); string customerName = Session["Name"].ToString(); IndentDTO indentDTO = new IndentDTO() { IndentId = activityModel.IndentId }; await _userActivityService.SaveExecutorForIndent(indentDTO, activityModel.UserOpponentId); string cacheKey = "show-indent-" + activityModel.IndentId.ToString(); IndentDTO cachedIndent = HttpContext.Cache[cacheKey] as IndentDTO; if (cachedIndent != null) { HttpContext.Cache.Remove(cacheKey); } NotificationDTO notificationDTO = GenerateNotification(activityModel, Role.Executor, "Сandidature confirmed"); notificationDTO.FromId = customerId; notificationDTO.FromName = customerName; await _userActivityService.SaveNotification(notificationDTO); return(RedirectToAction("ShowIndent", "Indent", new { id = activityModel.IndentId })); }
public async Task <IActionResult> Details(string id) { var model = UserActivityViewModel.MapFrom( await _collaborationService.GetActivitiesAsync(id), await _collaborationService.GetContributionsAsync(id), id); return(View(model)); }
public IActionResult Watch(string id) { var viewModel = new UserActivityViewModel(); viewModel.VideoID = id; viewModel.video = _context.Video.Find(id); return(View(viewModel)); }
public ActionResult DetaljiStudentaMenadzment(string students) { Student s = ctx.Student.Where(x => x.BrojIndeksa == students).FirstOrDefault(); UserActivityViewModel Model = new UserActivityViewModel(); Model.praceniStudent = s; return(View(Model)); }
public override ActionResult Index(IB_UserActivity currentBlock) { var userActivityViewModel = new UserActivityViewModel { BlockGuid = (currentBlock as IContent).ContentGuid }; return(PartialView("~/Views/Ignobilis/Blocks/UserActivity/index.cshtml", userActivityViewModel)); }
public ActionResult FamilyActivity(int?id) { List <User> userList = new List <User>(); userList = _db.GetAllUsersFromFamilyID(((User)Session["User"]).FamilyID); UserActivityViewModel model = new UserActivityViewModel(_db); model.UserList = userList; return(View("FamilyActivity", model)); }
public async Task <ActionResult> SaveExecutorRecallForCustomer(UserActivityViewModel activityModel) { var clientId = Session["Id"]; if (clientId == null) { return(RedirectToAction("Registration", "Executor")); } if (activityModel.Mark == null) { TempData["ErrorMessage"] = "Вы не оценили действия заказчика!"; return(RedirectToAction("ShowIndent", "Indent", new { id = activityModel.IndentId })); } int executorId = Convert.ToInt32(clientId); string executorName = Session["Name"].ToString(); RecallDTO recallDTO = new RecallDTO() { RecallId = activityModel.IndentId, ExecutorCommentForCustomer = activityModel.Comment, ExecutorMarkForCustomer = activityModel.Mark }; await _userActivityService.SaveExecutorRecallForCustomer(recallDTO); string cacheKeyForIndent = "show-indent-" + activityModel.IndentId.ToString(); IndentDTO cachedIndent = HttpContext.Cache[cacheKeyForIndent] as IndentDTO; if (cachedIndent != null) { HttpContext.Cache.Remove(cacheKeyForIndent); } string cacheKeyForCustomer = "show-customer-" + activityModel.UserOpponentId.ToString(); CustomerDTO cachedCustomer = HttpContext.Cache[cacheKeyForCustomer] as CustomerDTO; if (cachedCustomer != null) { HttpContext.Cache.Remove(cacheKeyForCustomer); } NotificationDTO notificationDTO = GenerateNotification(activityModel, Role.Customer, "Recall"); notificationDTO.FromId = executorId; notificationDTO.FromName = executorName; await _userActivityService.SaveNotification(notificationDTO); return(RedirectToAction("ShowIndent", "Indent", new { id = activityModel.IndentId })); }
public ActionResult UserActivity(UserActivityViewModel model) { model.LoginEvent = Request.Form["LoginEvent"] != "false"; model.CreateUserEvent = Request.Form["CreateUserEvent"] != "false"; model.ActivateUserEvent = Request.Form["ActivateUserEvent"] != "false"; model.DeactivateUserEvent = Request.Form["DeactivateUserEvent"] != "false"; model.ViewSetEvent = Request.Form["ViewSetEvent"] != "false"; model.ViewResourceEvent = Request.Form["ViewResourceEvent"] != "false"; model.DownloadResourceEvent = Request.Form["DownloadResourceEvent"] != "false"; this.UserActivityGetEvents(model); return(View(model)); }
public async Task <ActionResult> GetObservableUserActivities(string userName) { var activities = new UserActivityViewModel(); activities.UserName = userName; string primaryKey = _instaApi.GetPrimaryKeyByUsername(userName); activities.ProfilePictureUrl = await _instaApi.GetUserProfilePictureUriByPrimaryKeyAsync(primaryKey); var userActivities = (await _repository.GetListAsync <UserActivity>(x => x.InitiatorPrimaryKey == primaryKey)).ToList(); activities.Activities = userActivities; return(PartialView(activities)); }
public async Task <ActionResult> ManageClaims(string userID, string userName) { var activities = await _uow.Activities.GetAllAsync(); var userClaims = await _mgr.GetClaimsAsync(userID); var viewModel = new UserActivityViewModel { UserName = userName, Activities = activities, UserClaims = userClaims.ToList() }; return(View(viewModel)); }
public ActionResult Details(string students) { Student s = ctx.Student.Where(x => x.BrojIndeksa == students).FirstOrDefault(); UserActivityViewModel Model = new UserActivityViewModel(); ViewData["Greska"] = null; if (s != null) { int studentId = s.Id; if (!ModelState.IsValid) { Model.listaStudenata = ctx.Student.ToList(); return(View(Model)); } else { Model.praceniStudent = s; Model.objave = ctx.Objava.Where(x => x.StudentId == s.Id) .Include(x => x.Student) .Include(x => x.KategorijaObjave) .ToList(); Model.iznajmljeneKnjige = ctx.EvidencijaKnjigaZaIznajmljivanje .Where(x => x.StudentId == s.Id) .Include(x => x.Knjiga) .ToList(); Model.rezervisaneKnjige = ctx.Rezervacija .Where(x => x.StudentId == s.Id) .Include(x => x.Knjiga) .ToList(); Model.kategorijaObjave = ctx.KategorijaObjave.ToList(); Model.prijave = ctx.EvidencijaPrijava.Where(x => x.StudentId == s.Id).Include(x => x.Radnik).ToList(); } return(View(Model)); } else { ViewData["Greska"] = "Traženi student ne postoji u bazi!"; } return(null); }
public ActionResult AddReadingLog(UserActivityViewModel model) { ActionResult result = null; if (!ModelState.IsValid) { result = View("UserActivity", model); } else { model.MinutesRead = model.MinutesRead + (model.HoursRead * 60); ReadingLog log = new ReadingLog(); log.UserID = model.UserID; log.BookID = model.BookID; log.MinutesRead = model.MinutesRead; log.Status = model.Status; log.Type = model.Type; //date gets added in DAL log = _db.CreateReadingLog(log); var testID = TempData["RoleID"]; // book does not exist or ISBN is wrong if (log.ID == 0) { ModelState.AddModelError("invalid-credentials", "The reading log was not successfully created."); result = View("UserActivity", model); } else { Session["Log"] = log; //not sure if needed... yet? } if (((User)Session["User"]).RoleID == 2) { result = RedirectToAction("UserActivity", "Home"); } else if (((User)Session["User"]).RoleID == 3) { result = RedirectToAction("UserActivity", "Home"); } } return(result); }
private NotificationDTO GenerateNotification(UserActivityViewModel userActivityModel, Role roleOfPersonWhoWillGetNotification, string notificationType) { NotificationDTO notificationDTO = _mapper.Map <NotificationDTO>(userActivityModel); notificationDTO.RoleId = roleOfPersonWhoWillGetNotification; notificationDTO.WasRead = false; switch (notificationType) { case "Recall": notificationDTO.Context = "оставил(а) вам отзыв после работы над заказом"; break; case "Responce": notificationDTO.Context = "предлагает свою кандидатуру для выполнения заказа"; break; case "Сandidature confirmed": notificationDTO.Context = "выбрал(а) вас для выполнения заказа"; break; case "Invite to complete order": notificationDTO.Context = "предлагает вам выполнить заказ"; break; default: notificationDTO.Context = "оставил(а) вам отзыв после работы над заказом"; break; } return(notificationDTO); }
public ActionResult UserActivity() { var model = new UserActivityViewModel(); DateTime now = DateTime.UtcNow; DateTime localnow = DateTimeHelper.ToLocalTime(now); model.FromDate = localnow.AddDays(-7); model.ToDate = localnow; model.LoginEvent = true; model.CreateUserEvent = true; model.ActivateUserEvent = true; model.DeactivateUserEvent = true; model.ViewSetEvent = true; model.ViewResourceEvent = true; model.DownloadResourceEvent = true; model.CurrentPage = 1; this.UserActivityGetEvents(model); return(View(model)); }
public virtual async Task <ActionResult> UserActivity( Guid userId, Guid?siteId, int pageNumber = 1, int pageSize = 10 ) { if (userId == Guid.Empty) { return(RedirectToAction("Index")); } var selectedSite = await SiteManager.GetSiteForDataOperations(siteId); var user = await UserManager.Fetch(selectedSite.Id, userId); if (user == null) { return(RedirectToAction("Index")); } // only server admin site can edit other sites settings if (selectedSite.Id != SiteManager.CurrentSite.Id) { ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["{0} - User Activity - {1}"], selectedSite.SiteName, user.Email); } else { ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["User Activity - {0}"], user.Email); } var model = new UserActivityViewModel { SiteId = selectedSite.Id, UserId = user.Id, CreatedUtc = user.CreatedUtc, DisplayName = user.DisplayName, Email = user.Email, AvatarUrl = user.AvatarUrl, FirstName = user.FirstName, LastLoginUtc = user.LastLoginUtc, LastName = user.LastName, LastPassswordChangenUtc = user.LastPasswordChangeUtc, TimeZoneId = await TimeZoneIdResolver.GetUserTimeZoneId(), Locations = await UserManager.GetUserLocations( selectedSite.Id, userId, pageNumber, pageSize ), TwoFactor = user.TwoFactorEnabled, Logins = await UserManager.GetLoginsAsync(user as SiteUser) }; if (!string.IsNullOrWhiteSpace(user.TimeZoneId)) { model.UserTimeZone = user.TimeZoneId; } else { model.UserTimeZone = UserManager.Site.TimeZoneId; } var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext) { KeyToAdjust = "UserActivity", AdjustedText = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["Activity - {0}"], user.Email), ViewFilterName = NamedNavigationFilters.Breadcrumbs // this is default but showing here for readers of code }; currentCrumbAdjuster.AddToContext(); return(View(model)); }
public ActionResult Index() { var activityModel = new UserActivityViewModel(); return(View(activityModel)); }
private void UserActivityGetEvents(UserActivityViewModel model) { IList <int> userEventTypes = new List <int>(); if (model.LoginEvent) { userEventTypes.Add((int)UserEventType.Login); } if (model.CreateUserEvent) { userEventTypes.Add((int)UserEventType.Create); } if (model.ActivateUserEvent) { userEventTypes.Add((int)UserEventType.Activation); } if (model.DeactivateUserEvent) { userEventTypes.Add((int)UserEventType.Deactivation); } IList <int> setEventTypes = new List <int>(); if (model.ViewSetEvent) { setEventTypes.Add((int)EventType.View); } IList <int> resourceEventTypes = new List <int>(); if (model.ViewResourceEvent) { resourceEventTypes.Add((int)EventType.View); } if (model.DownloadResourceEvent) { resourceEventTypes.Add((int)EventType.Download); } User user = null; if (!string.IsNullOrEmpty(model.SelectedUserName)) { user = this.userService.SearchUsers(model.SelectedUserName).FirstOrDefault(); if (user == null) { this.ModelState.AddModelError("SelectedUserName", "Unknown User"); } } if (this.ModelState.IsValid) { DateTime fromdate = DateTimeHelper.FromLocalTime(model.FromDate); DateTime todate = DateTimeHelper.FromLocalTime(NormalizeToDate(model.ToDate)); var totalPages = 0; if (user == null) { model.GenericEvents = this.reportService.GetUserEvents(fromdate, todate, userEventTypes, setEventTypes, resourceEventTypes, DefaultPageSize, model.CurrentPage, out totalPages); } else { model.GenericEvents = this.reportService.GetUserEventsByUser(fromdate, todate, userEventTypes, setEventTypes, resourceEventTypes, user.UserId, DefaultPageSize, model.CurrentPage, out totalPages); } model.TotalPages = totalPages; } }
public IActionResult UserActivity() { var activityModel = new UserActivityViewModel(); return(Ok(activityModel)); }
public async Task <ActionResult> OfferIndentToExecutor(int fromId, string fromName, UserActivityViewModel activityModel) { NotificationDTO notificationDTO = GenerateNotification(activityModel, Role.Executor, "Invite to complete order"); notificationDTO.FromId = fromId; notificationDTO.FromName = fromName; await _userActivityService.SaveNotification(notificationDTO); return(RedirectToAction("ShowExecutor", "Executor", new { id = activityModel.UserOpponentId })); }
public async Task <ActionResult> SaveExecutorResponce(UserActivityViewModel activityModel, string indentPrice) { var clientId = Session["Id"]; if (clientId == null) { return(RedirectToAction("Registration", "Executor")); } int executorId = Convert.ToInt32(clientId); string executorName = Session["Name"].ToString(); double?priceOfIndent; Regex patternForPrice = new Regex(@"^[0-9]*\,?[0-9]+\s?$", RegexOptions.IgnoreCase); if (indentPrice == null) { priceOfIndent = null; } else if (patternForPrice.IsMatch(indentPrice.Trim())) { try { priceOfIndent = Convert.ToDouble(indentPrice.Trim()); } catch (Exception e) { TempData["ErrorMessage"] = "Были введены некорректные данные, попробуйте снова!"; return(RedirectToAction("ShowIndent", "Indent", new { id = activityModel.IndentId })); } } else { TempData["ErrorMessage"] = "Были введены некорректные данные, попробуйте снова!"; return(RedirectToAction("ShowIndent", "Indent", new { id = activityModel.IndentId })); } ResponceDTO responceDTO = new ResponceDTO() { Price = priceOfIndent, IndentId = activityModel.IndentId, Executor = new ExecutorDTO() { ExecutorId = executorId }, ResponceText = activityModel.Comment }; await _userActivityService.SaveResponce(responceDTO); string cacheKey = "show-indent-" + activityModel.IndentId.ToString(); IndentDTO cachedIndent = HttpContext.Cache[cacheKey] as IndentDTO; if (cachedIndent != null) { HttpContext.Cache.Remove(cacheKey); } NotificationDTO notificationDTO = GenerateNotification(activityModel, Role.Customer, "Responce"); notificationDTO.FromId = executorId; notificationDTO.FromName = executorName; await _userActivityService.SaveNotification(notificationDTO); return(RedirectToAction("ShowIndent", "Indent", new { id = activityModel.IndentId })); }
void analyzeByActivity(IEnumerable <UserActivityLog> logs, int activity, int moduleId, string dateFormat, bool dayOneLogs) { AppModules module = (AppModules)moduleId; var total = dayOneLogs == true?logs.Where(l => l.UserActivityID == activity).Count() : logs.Where(l => l.UserActivityID == activity).GroupBy(l => l.EntityID).Count(); //var total = logs.Where(l => l.UserActivityID == activity).GroupBy(l => l.EntityID).Select(g => g.First()).Count(); //var entityDetails = logs.Where(l => l.UserActivityID == activity && l.ModuleID == moduleId).Select(l => l.EntityDetail).ToList(); if (total == 0) { return; } string totalInText = string.Empty; int[] anEntities = new int[] { 1, 5, 16 }; if (total == 1) { totalInText = anEntities.Contains(moduleId) ? "[|an|]" : "[|a|]"; } else { totalInText = total.ToString(); } //var date = logs.Where(l => l.UserActivityID == activity).First().LogDate; //string message = ""; List <UserActivityViewModel> userActivityModels = new List <UserActivityViewModel>(); if (dayOneLogs) { totalInText = anEntities.Contains(moduleId) ? "[|an|]" : "[|a|]"; var activityLogs = logs.Where(l => l.UserActivityID == activity); foreach (var log in activityLogs) { UserActivityViewModel userActivityModel = new UserActivityViewModel(); userActivityModel.DateFormat = dateFormat; userActivityModel.EntityIds = new List <int>() { log.EntityID }; userActivityModel.Message = ((AppModules)moduleId == AppModules.Reports || (AppModules)moduleId == AppModules.AdvancedSearch && activity == (byte)UserActivityType.LastRunOn) ? "[|Ran|] " + totalInText + " " + ((AppModules)moduleId == AppModules.Reports ? " [|Report|]" : " [|Saved Search|]") + " - " + log.EntityName : (activities[activity] + " " + totalInText + " " + modules[module] + " - " + log.EntityName); userActivityModel.LogDate = log.LogDate; userActivityModel.ModuleID = (byte)moduleId; if (dateFormat.Contains('/')) { userActivityModel.DateSeperator = dtfi; } userActivityModels.Add(userActivityModel); } analysis.AddRange(userActivityModels); } else { var date = logs.Where(l => l.UserActivityID == activity).First().LogDate; string message = ((AppModules)moduleId == AppModules.Reports || (AppModules)moduleId == AppModules.AdvancedSearch && activity == (byte)UserActivityType.LastRunOn ? "[|Ran|]" : activities[activity]) + " " + totalInText + " " + (total > 1 ? modules[module] + "[|s|]" : modules[module]) + " " + ("- " + logs.Where(l => l.UserActivityID == activity).GroupBy(l => l.EntityID).Select(g => g.FirstOrDefault().EntityName).Aggregate((a, b) => a + ", " + b)); UserActivityViewModel model = new UserActivityViewModel(); model.DateFormat = dateFormat; model.Message = message; model.EntityIds = logs.Where(l => l.UserActivityID == activity).Select(s => s.EntityID).Distinct().ToList(); // model.EntityDetails = entityDetails; model.LogDate = date; // model.EntityId = model.ModuleID = (byte)moduleId; if (dateFormat.Contains('/')) { model.DateSeperator = dtfi; } analysis.Add(model); } }
public View_UserActivity() { InitializeComponent(); BindingContext = new UserActivityViewModel(Navigation); }