public void ReceiveTelemetryMessage_ExpectTelemetryMessageStored() { EventAggregatorMock eventAggregatorMock = new EventAggregatorMock(); eventAggregatorMock.AddPubSubEvent <TelemetryUpdateEvent, TelemetryUpdateEventArgs>(); IEventAggregator eventAggregator = eventAggregatorMock; ITelemetryReceiver telemetryReceiver = Substitute.For <ITelemetryReceiver>(); MainViewModel mainViewModel = new MainViewModel(eventAggregator, telemetryReceiver); ActivityLogViewModel activityLogViewModel = mainViewModel.ActivityLogViewModel; ReceivedTelemetryEventArgs eventArgs = new ReceivedTelemetryEventArgs( telemetryType: FAILURE_MESSAGE_TYPE, message: FAILURE_MESSAGE, sender: FAILURE_MESSAGE_SENDER, receiver: FAILURE_MESSAGE_RECEIVER, timestamp: DateTime.Now); mainViewModel.StartReceiveNotificationsCommand.Execute(); telemetryReceiver.NotificationReceived += Raise.EventWith(this, eventArgs); Assert.AreEqual(RECEIVE_MESSAGES_COUNT, activityLogViewModel.Activities.Count); Assert.AreEqual(FAILURE_MESSAGE_TYPE, activityLogViewModel.Activities.First().EventType); Assert.AreEqual(FAILURE_MESSAGE_SENDER, activityLogViewModel.Activities.First().Sender); Assert.AreEqual(FAILURE_MESSAGE, activityLogViewModel.Activities.First().Message); }
//[HttpPost] //[ValidateAntiForgeryToken] public async Task <bool> LogAddAccion(ActivityLogViewModel model) { if (ModelState.IsValid) { var user = await _userHelper.GetUserByEmailAsync(model.UserEMail); if (user != null) { var Registro = new ActivityLog(); Registro.Date = DateTime.Now; Registro.Ip = NetworkHelper.GetIPClient(); Registro.MacAddress = NetworkHelper.GetMacAdreessDeviceClient(); Registro.NameDevice = NetworkHelper.GetNameDeviceClient(); Registro.UserId = user.Id; Registro.UserEMail = user.Email; Registro.UserFullName = user.FullName; Registro.Controller = model.Controller; Registro.Action = model.Action; Registro.Description = model.Description; Registro.Status = model.Status; Registro.Type = model.Type; _dataContext.Add(Registro); await _dataContext.SaveChangesAsync(); return(true); } } return(false); }
public async Task <IActionResult> OnPost(string returnUrl = null) { var Email = User.Identity.Name; await _signInManager.SignOutAsync(); _logger.LogInformation("User logged out."); //Log var Model = new ActivityLogViewModel { UserEMail = Email, Action = "Logout", Description = "User logged out.", Controller = "Account", Status = false, Type = "AppWeb" }; var logIsSuccees = await _LogToDB.Create(Model); // if (returnUrl != null) { return(LocalRedirect(returnUrl)); } else { return(RedirectToPage()); } }
public ActionResult Create(ActivityLogViewModel activityLog) { try { if (ModelState.IsValid) { ActivityLogService.Insert(activityLog); TempData["UserMessage"] = new CRUDNotification() { NotificationType = CRUDNotification.NotificationTypes.Success, Message = "Activity Log Added Successfully." }; return(RedirectToAction("Index", new { id = activityLog.ActivityId })); } else { TempData["UserMessage"] = new CRUDNotification() { NotificationType = CRUDNotification.NotificationTypes.Warning, Message = "Please fix issues on the page to continue." }; return(View(activityLog)); } } catch (Exception ex) { TempData["UserMessage"] = new CRUDNotification() { NotificationType = CRUDNotification.NotificationTypes.Error, Message = "Error adding activity log <br/>" + ex.Message }; return(View(activityLog)); } }
public IActionResult Index() { var events = _employeeService.GetChangeEvents(); ActivityLogViewModel model = new ActivityLogViewModel(events); return(View(model)); }
//GET: LogActivity public ActionResult LogActivity() { var exerciseTypes = _context.ExerciseTypes.ToList(); var activityViewModel = new ActivityLogViewModel { ExerciseType = exerciseTypes, }; return(View(activityViewModel)); }
public void Update(ActivityLogViewModel activityLogInfo) { var activityLog = Repository.GetById(activityLogInfo.Id); activityLog.ActivityId = activityLogInfo.ActivityId; activityLog.Mood = activityLogInfo.Mood; activityLog.Note = activityLogInfo.Note; activityLog.IsArchived = activityLogInfo.IsArchived; Repository.Update(activityLog); UnitOfWork.SaveChanges(); }
public void Insert(ActivityLogViewModel activityLog) { var activityLogInfo = new ActivityLog() { ActivityId = activityLog.ActivityId, Mood = activityLog.Mood, Note = activityLog.Note }; Repository.Insert(activityLogInfo); UnitOfWork.SaveChanges(); }
public ActionResult LogActivity(ActivityLogViewModel activityViewModel) { //ToDoItems //Ensure ActivityDate is not before iimstart date and not after startdate + duration //Some sort of validation needed to ensure values are not null string appUserId = User.Identity.GetUserId(); double?distance; if (activityViewModel.ActivityLog.ExerciseTypeModelsId != bikeId && activityViewModel.ActivityLog.ExerciseTypeModelsId != swimId && activityViewModel.ActivityLog.ExerciseTypeModelsId != runId) { distance = _distanceCalculator.GetDistance(activityViewModel); } else { distance = activityViewModel.ActivityLog.Distance; } var activityLog = new ActivityLogModels { ActivityDate = activityViewModel.ActivityLog.ActivityDate, Distance = distance, DurationInMinutes = activityViewModel.ActivityLog.DurationInMinutes, ExerciseTypeModelsId = activityViewModel.ActivityLog.ExerciseTypeModelsId, ApplicationUserId = appUserId }; var actvityLogIdTest = activityViewModel.ActivityLog.Id; var actvityLogIdTest2 = activityLog.Id; if (activityViewModel.ActivityLog.Id == 0) { _context.ActivityLogs.Add(activityLog); } else { var activityInLog = _context.ActivityLogs.Single(currentActivity => currentActivity.Id == activityViewModel.ActivityLog.Id); activityInLog.ActivityDate = activityLog.ActivityDate; activityInLog.Distance = activityLog.Distance; activityInLog.DurationInMinutes = activityLog.DurationInMinutes; activityInLog.ExerciseTypeModelsId = activityLog.ExerciseTypeModelsId; } _context.SaveChanges(); return(RedirectToAction("LogActivity", "Participant")); }
public ActionResult UserActivity(ActivityLogViewModel model) { int currentPage = 1; int pageSize = AdminSettings.PageSize; if (string.IsNullOrEmpty(model.SearchExec)) { model.SearchExec = "Y"; if (!ModelState.IsValid) { ModelState.Clear(); } } if (Request["Page"] != null) { currentPage = Convert.ToInt32(Request["Page"]); } var str_min = DateTime.MinValue.Year + "-" + DateTime.MinValue.Month + "-" + DateTime.MinValue.Day; var str_now = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day; var parms = new ActivityLogQueryParms { Email = model.Email != null ? model.Email : string.Empty, ActivityText = model.ActivityText != null ? model.ActivityText : string.Empty, ActivityType = model.ActivityType != null ? model.ActivityType : string.Empty, FromDate = model.FromDate != null ? model.FromDate : str_min, ToDate = model.ToDate != null ? model.ToDate : str_now, PageSize = pageSize, CurrentPage = currentPage }; try { model.SearchResults = _activityStore.FilterActivityLog(parms); model.Total = _activityStore.CountAllFilterActivityLog(parms); model.CurrentPage = currentPage; model.PageNo = (model.Total + pageSize - 1) / pageSize; model.PageSize = pageSize; } catch (Exception ex) { this.AddNotification("Failed to get data because: " + ex.ToString(), NotificationType.ERROR); return(View(model)); } return(View(model)); }
public ActionResult Create(int id = 0) { if (id > 0) { var activityLog = new ActivityLogViewModel() { ActivityId = id }; return(View(activityLog)); } else { return(RedirectToAction("index", "activity")); } }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, set lockoutOnFailure: true var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure : false); if (result.Succeeded) { _logger.LogInformation("User logged in."); //Log var Model = new ActivityLogViewModel { UserEMail = Input.Email, Action = "Login", Description = "User logged in", Controller = "Account", Status = true, Type = "AppWeb" }; var logIsSuccees = await _LogToDB.Create(Model); // return(LocalRedirect(returnUrl)); } if (result.RequiresTwoFactor) { return(RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, RememberMe = Input.RememberMe })); } if (result.IsLockedOut) { _logger.LogWarning("User account locked out."); return(RedirectToPage("./Lockout")); } else { ModelState.AddModelError(string.Empty, "Invalid login attempt."); return(Page()); } } // If we got this far, something failed, redisplay form return(Page()); }
public ActionResult ActivityLog() { var userId = User.Identity.GetUserId(); var user = GetUserById(userId); var activityLogs = (from a in DbContext.UserLogs where a.UserName == user.UserName select a).ToList(); var model = new ActivityLogViewModel() { UserName = user.UserName, UserLogs = activityLogs }; return(View(model)); }
public double?GetDistance(ActivityLogViewModel activityLogViewModel) { switch (activityLogViewModel.ActivityLog.ExerciseTypeModelsId) { case RowId: distance = RowMultiplier * activityLogViewModel.ActivityLog.DurationInMinutes; break; case SpinId: distance = SpinMultiplier * activityLogViewModel.ActivityLog.DurationInMinutes; break; case WaterAerobicsId: distance = WaterAerobicsMultiplier * activityLogViewModel.ActivityLog.DurationInMinutes; break; } return(distance); }
public ActionResult Edit(int id) { var activityLog = _context.ActivityLogs.SingleOrDefault(u => u.Id == id); if (activityLog == null) { return(HttpNotFound()); } string appUserId = User.Identity.GetUserId(); var activityLogViewModel = new ActivityLogViewModel { ApplicationUser = _context.Users.Single(u => u.Id == appUserId), ExerciseType = _context.ExerciseTypes.ToList(), ActivityLog = activityLog }; return(View("LogActivity", activityLogViewModel)); }
public ActionResult Unarchive(ActivityLogViewModel activityLog) { try { ActivityLogService.Unarchive(activityLog.Id); TempData["UserMessage"] = new CRUDNotification() { NotificationType = CRUDNotification.NotificationTypes.Success, Message = "Activity Log unarchived successfully." }; return(RedirectToAction("Index", new { id = activityLog.ActivityId })); } catch (Exception ex) { TempData["UserMessage"] = new CRUDNotification() { NotificationType = CRUDNotification.NotificationTypes.Error, Message = "Error unarchiving Activity Log " + ex.Message }; return(View(activityLog)); } }
public void Post([FromBody] ActivityLogViewModel log) { var activityLog = Mapper.Map <ActivityLog>(log); this.activityLogService.Create(activityLog); }