private async void OnActionPaused(RunningActionViewModel sender, UserAction userAction) { await Navigation.PushAsync(new FinishedActionDetails() { BindingContext = await UserActionViewModel.FromAction(userAction) }); }
public List <UserActionViewModel> GetUserActionList(int userId) { List <UserActionViewModel> userActions = new List <UserActionViewModel>(); var actions = SysActionDao.GetList(x => true).OrderBy(x => x.SortCode).ToList(); var myUserActions = GetList(x => x.UserId == userId).ToList(); foreach (var item in actions) { UserActionViewModel viewModel = new UserActionViewModel(); viewModel.Id = item.Id; viewModel.ParentId = item.ParentId; viewModel.Code = item.Code; viewModel.Name = item.Name; var myUserAction = myUserActions.Where(x => x.ActionId == item.Id).FirstOrDefault(); if (myUserAction != null) { if (myUserAction.HasPermisssin) { viewModel.Status = 1; } else { viewModel.Status = 2; } } userActions.Add(viewModel); } return(userActions); }
private void RunAction(DisplayToDoViewModel sender, object data) { var userActionDM = data as UserActionDisplayModel; if (userActionDM is null) { DisplayAlert("Error", "Error", "Ok"); return; } var userActionVM = new UserActionViewModel { Id = userActionDM.ID, Date = userActionDM.Date, ActionContext = userActionDM.ActionContext, StartTime = userActionDM.StartTime, EndTime = userActionDM.EndTime, Status = userActionDM.Status, Title = userActionDM.Title }; var userAction = userActionVM.GetAction(); Navigation.PushAsync(new Pages.ActionStates.RunningActionPage() { BindingContext = new RunningActionViewModel(userAction, userActionDM.ActionContext) }); }
public async Task <IActionResult> UserAction(UserActionViewModel model) { // Retrieve requested metric var metric = await _metricService.GetOrCreateMetricAsync(Metrics.UserAction, model.Source); // Retrieve requested user action var userAction = await _context.UserActions.FirstAsync(act => act.Id == model.UserAction.AsInt()); // Record data await _context .UserActionDataPoints .AddAsync( new UserActionDataPoint { Count = model.Count, Action = userAction, Metric = metric } ); // Submit changes to data provider await _context.SaveChangesAsync(); return(Ok("Data point has been recorded.")); }
public async Task <IActionResult> AddAction( [FromBody] UserActionViewModel model) { await _actionService.AddAction(model).ConfigureAwait(false); return(Ok()); }
public async Task <ActionResult> Delete(string ID) { UserActionViewModel model = new UserActionViewModel(); var user = await UserManager.FindByIdAsync(ID); // find users based on param ID model.ID = user.Id; return(PartialView("_Delete", model)); }
public async Task AddAction(UserActionViewModel userAction) { _unitOfWorkService.Service <BO.Models.Action>().Add(new BO.Models.Action { UserId = userAction.UserId, Platform = userAction.Platform, UserDisplayName = userAction.UserDisplayName, Message = userAction.Message, ActionDate = DateTime.Now.Date }); await _unitOfWorkService.SaveAsync().ConfigureAwait(false); }
public async Task <JsonResult> Action(UserActionViewModel model) { JsonResult json = new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet }; IdentityResult result; // decalre IdentityResult if (!string.IsNullOrEmpty(model.ID)) // Editing record { var user = await UserManager.FindByIdAsync(model.ID); // find users based on param ID user.FullName = model.FullName; user.Email = model.Email; user.UserName = model.Username; user.Country = model.Country; user.City = model.City; user.Address = model.Address; //model.AccomadationPackageID = accomadations.AccomadationPackageID; result = await UserManager.UpdateAsync(user); // update HMSUser table in databse } else // Saving record { HMSUser user = new HMSUser { FullName = model.FullName, Email = model.Email, UserName = model.Username, Country = model.Country, City = model.City, Address = model.Address, //model.AccomadationPackageID = accomadations.AccomadationPackageID; }; result = await UserManager.CreateAsync(user); // create user in HMSUser table in databse without a password } // show true if result is success otherwise false and show the result error json.Data = new { Success = result.Succeeded, Message = string.Join(",", result.Errors) }; return(json); }
public async Task <JsonResult> Delete(UserActionViewModel model) { JsonResult json = new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet }; if (!string.IsNullOrEmpty(model.ID)) // Editing record { var user = await UserManager.FindByIdAsync(model.ID); IdentityResult result = await UserManager.DeleteAsync(user); json.Data = new { Success = result.Succeeded, Message = string.Join(",", result.Errors) }; } else { json.Data = new { Success = false, Message = "Invalid User" }; } return(json); }
// Both 'Action' methods are used for Create and Edit public async Task <ActionResult> Action(string ID) // have to make method async as we are finding users async { UserActionViewModel model = new UserActionViewModel(); if (!string.IsNullOrEmpty(ID)) // Editing record { var users = await UserManager.FindByIdAsync(ID); // find users based on param ID model.ID = users.Id; model.FullName = users.FullName; model.Email = users.Email; model.Username = users.UserName; model.Country = users.Country; model.City = users.City; model.Address = users.Address; //model.AccomadationPackageID = accomadations.AccomadationPackageID; } model.Roles = RolesManager.Roles; return(PartialView("_Action", model)); }