public ActionResult CriarChange(ChangeViewModel model) { model.FuncionarioId = Convert.ToInt32(Session["UserId"]); model.PrioridadeId = Convert.ToInt32(Request.Form["Prioridades"]); _changeService.CriarChange(model); return(RedirectToAction("ListarChanges", "Assistencia")); }
// GET: Changes/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var change = await _uow.Changes.FindAsync(id); if (change == null) { return(NotFound()); } var viewModel = new ChangeViewModel { Change = change, Categories = new SelectList(await _uow.Categories.AllAsync(), nameof(Category.Id), nameof(Category.CategoryName)), Organizations = new SelectList(await _uow.Organizations.AllAsync(), nameof(Organization.Id), nameof(Organization.OrganizationName)) }; return(View(viewModel)); }
public async Task <IActionResult> ConfirmChange(ChangeViewModel model, int idShift, int idShift2, int idService, int idService2) { ChangeEntity changeEntity = await _converterHelper.ToChangeEntityAsync(model, false); changeEntity.State = "Approved"; _context.Update(changeEntity); await _context.SaveChangesAsync(); ShiftEntity shiftEntity = await _context.Shifts.Include(s => s.User).Include(s => s.Service). FirstOrDefaultAsync(s => s.Id == idShift); shiftEntity.Service = await _context.Services.Include(s => s.ServiceDetail). FirstOrDefaultAsync(s => s.Id == idService); ShiftEntity shiftEntity2 = await _context.Shifts.Include(s => s.User).Include(s => s.Service). FirstOrDefaultAsync(s => s.Id == idShift2); shiftEntity2.Service = await _context.Services.Include(s => s.ServiceDetail). FirstOrDefaultAsync(s => s.Id == idService2); shiftEntity.Modified = true; shiftEntity2.Modified = true; _context.Update(shiftEntity); await _context.SaveChangesAsync(); _context.Update(shiftEntity2); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(SelectChanges))); }
public async Task <ActionResult> Change(ChangeViewModel model) { if (ModelState.IsValid) { var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); if (!string.IsNullOrEmpty(model.FirstName)) { user.FirstName = model.FirstName; } if (!string.IsNullOrEmpty(model.LastName)) { user.LastName = model.LastName; } if (!string.IsNullOrEmpty(model.Email)) { user.Email = model.Email; } if (!string.IsNullOrEmpty(model.Username)) { user.UserName = model.Username; } await UserManager.UpdateAsync(user); return(RedirectToAction("Index")); } return(View()); }
public async Task <IActionResult> Edit(int id, [Bind] Change change) { if (id != change.Id) { return(NotFound()); } if (ModelState.IsValid) { _uow.Changes.Update(change); await _uow.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } var viewModel = new ChangeViewModel { Change = change, Categories = new SelectList(await _uow.Categories.AllAsync(), nameof(Category.Id), nameof(Category.CategoryName)), Organizations = new SelectList(await _uow.Organizations.AllAsync(), nameof(Organization.Id), nameof(Organization.OrganizationName)) }; return(View(viewModel)); }
public ActionResult CriarChange() { var itemsPrioridade = _prioridadeService.ListarPrioridades(); var vm = new ChangeViewModel() { Prioridades = itemsPrioridade.ToList(), }; return(View(vm)); }
// GET: Changes/Create public async Task <IActionResult> Create() { var viewModel = new ChangeViewModel { Categories = new SelectList(await _uow.Categories.AllAsync(), nameof(Category.Id), nameof(Category.CategoryName)), Organizations = new SelectList(await _uow.Organizations.AllAsync(), nameof(Organization.Id), nameof(Organization.OrganizationName)) }; return(View(viewModel)); }
public async Task <IActionResult> CreateChange(ChangeViewModel model) { if (ModelState.IsValid) { ChangeEntity changeEntity = await _converterHelper.ToChangeEntityAsync(model, true); _context.Add(changeEntity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public async Task <ChangeEntity> ToChangeEntityAsync(ChangeViewModel model, bool isNew) { return(new ChangeEntity { Id = model.Id, Date = DateTime.Today.AddDays(1).ToUniversalTime(), FirstDriver = await _context.Users.FindAsync(model.FirstDriverId), FirstDriverService = await _context.Shifts.FindAsync(model.FirstDriverServiceId), SecondDriver = await _context.Users.FindAsync(model.SecondDriverId), SecondDriverService = await _context.Shifts.FindAsync(model.SecondDriverServiceId), State = "Pending" }); }
public ActionResult ChangeInfo(ChangeViewModel model) { Customer c = CustomerRepository.FindBy(User.Identity.GetUserName()); // UserManager.SetEmail(User.Identity.GetUserId(), model.Email); // c.Email = model.Email; c.Naam = model.Naam; c.Voornaam = model.Voornaam; c.VerenigingBedrijf = model.VerenigingOfBedrijf; c.CustomerName = model.Voornaam + model.Naam; CustomerRepository.SaveChanges(); TempData["info"] = "Uw gegevens werden aangepast"; return(RedirectToAction("Index")); }
public ActionResult Change(ChangeViewModel model) { if (ModelState.IsValid) { Role role = null; if (model.Roles != null) { role = model.Roles.FirstOrDefault(x => x.Selected == true); } // наполняем объект данными User user = new User() { Id = model.Id, UserName = model.UserName, Password = model.Password, Name = model.Name, LastName = model.LastName, MiddleName = model.MiddleName, Email = model.Email, IsActive = model.IsActive ? 1 : 0, IsSuperuser = model.Superuser ? 1 : 0, Role = role }; // обновление данных пользователя if (account.ChangeUser(user)) { // лог logging.Logged( "Info" , "Пользователь '" + User.Identity.Name + "' изменил данные пользователя: '" + model.UserName + "'" , this.GetType().Namespace , this.GetType().Name ); return(Json(new { result = "Redirect", url = Url.Action("User", "System") })); } else { ModelState.AddModelError("", "Этот пользователь уже зарегистрирован"); } } else { ModelState.AddModelError("", "Ошибка, пожалуйста проверьте данные"); } return(PartialView(model)); }
void UpdateView(ChangeViewModel model) { ChangeView.DisableShadows(); ChangeView.SchoolClassLabel.Text = model.ClassName; ChangeView.HoursLabel.Text = model.Day + ", " + model.Hours + " " + NSBundle.MainBundle.LocalizedString("change_suffix_hour", ""); ChangeView.ChangeLabel.Text = NSBundle.MainBundle.LocalizedString(model.Type, ""); ChangeView.SchoolGradientView.Gradient = model.FillColor; ChangeView.OriginalLessonLabel.AttributedText = TextComponentFormatter.AttributedStringForTextComponents(model.OldLesson, true); ChangeView.ChangeDescriptionLabel.AttributedText = TextComponentFormatter.AttributedStringForTextComponents(model.Description, false); // Calculate the dynamic content size with the width restricted to the view's width and a boundless height. // Set the priority for the width to required (so it doesn't get larger than the available space) the priority of the height to low PreferredContentSize = ChangeView.SystemLayoutSizeFittingSize(new CoreGraphics.CGSize(View.Bounds.Size.Width, nfloat.MaxValue), 1000, 100); }
public ActionResult GetChange() //Возврат сдачи { Dictionary <string, int> dict = CoinService.GetChange(GetTotal()); int total = dict["$remain"]; dict.Remove("$remain"); SetTotal(total); var change = new ChangeViewModel(); change.Status = total == 0 ? 1 : 0; change.Wallet = dict; TempData["message"] = change; return(RedirectToAction("Index")); }
public async Task <IActionResult> ConfirmChange(int id) { ChangeEntity changeEntity = await _context.Changes.Include(c => c.FirstDriver). Include(c => c.FirstDriverService). ThenInclude(c => c.Service). ThenInclude(s => s.ServiceDetail). Include(c => c.SecondDriver). Include(c => c.SecondDriverService). ThenInclude(s => s.Service). ThenInclude(s => s.ServiceDetail). FirstOrDefaultAsync(c => c.Id == id); ChangeViewModel change = _converterHelper.ToChangeViewModel(changeEntity); return(View(change)); }
public ActionResult UserPwd(ChangeViewModel viewModel) { string userName = CookieHelper.GetCookieValue("UserName").ToString(); if (AuthorizeManager.ChangePassword(userName, viewModel.OldPassword, viewModel.Password)) { viewModel.IsSuccess = true; viewModel.SuccessMessage = "密码修改成功!"; } else { viewModel.IsSuccess = false; viewModel.SuccessMessage = "密码修改失败,请重试!"; } return(View(viewModel)); }
// private helper methods private static ChangeViewModel CreateChangeViewModel(Change change) { var result = new ChangeViewModel { Changeset = change.Changeset, Action = change.Action, EntityId = change.EntityId, EntityType = change.EntityType }; if (change.Action != ChangeAction.Delete.ToString()) { result.Key = change.Key; result.Value = change.Value; } return(result); }
public void UpdateChange(ChangeViewModel cg) { Change p = new Change { Descricao = cg.Descricao, Titulo = cg.Titulo, Id = cg.Id, AreasImpactadas = cg.AreasImpactadas, DiaFim = cg.DiaFim, DiaInicio = cg.DiaInicio, LocalMudanca = cg.LocalMudanca, PodeTerRollback = cg.PodeTerRollback, PrioridadeId = cg.PrioridadeId, FuncionarioId = cg.FuncionarioId }; _repository.Update(p); }
public void CriarChange(ChangeViewModel cg) { Change c = new Change { Descricao = cg.Descricao, FuncionarioId = cg.FuncionarioId, Titulo = cg.Titulo, Email = cg.Email, Username = cg.Username, AreasImpactadas = cg.AreasImpactadas, DiaFim = cg.DiaFim, DiaInicio = cg.DiaInicio, LocalMudanca = cg.LocalMudanca, PodeTerRollback = cg.PodeTerRollback, PrioridadeId = cg.PrioridadeId }; _repository.Insert(c); }
public async Task <IActionResult> CreateChange(int idShift) { Task <bool> checkHours; DateTime tomorrow = DateTime.Today.AddDays(1).ToUniversalTime(); UserEntity firstDriver = await _userHelper.GetUserAsync(User.Identity.Name); ShiftEntity firstShift = await _context.Shifts. Include(s => s.User). Include(s => s.Service). Where(s => s.Date == tomorrow).FirstOrDefaultAsync(s => s.User == firstDriver); ShiftEntity secondShift = await _context.Shifts.Include(s => s.Service). Include(s => s.User).FirstOrDefaultAsync(s => s.Id == idShift); UserEntity secondDriver = secondShift.User; checkHours = _changeHelper.CheckHours(firstDriver, secondShift); if (!checkHours.Result) { TempData["msg"] = "<script>alert('Dont satisfy 10 hours of rest');</script>"; return(RedirectToAction("Index", "Changes")); } ChangeViewModel model = new ChangeViewModel { FirstDriver = firstDriver, FirstDriverId = firstDriver.Id, FirstDriverService = firstShift, FirstDriverServiceId = firstShift.Id, SecondDriver = secondDriver, SecondDriverId = secondDriver.Id, SecondDriverService = secondShift, SecondDriverServiceId = secondShift.Id, }; return(View(model)); }
public ActionResult EditarChange(int id) { var selecionarChange = _changeService.GetChange(id); var itemsPrioridade = _prioridadeService.ListarPrioridades(); var vm = new ChangeViewModel() { Descricao = selecionarChange.Descricao, Id = selecionarChange.Id, Titulo = selecionarChange.Titulo, Email = selecionarChange.Email, Username = selecionarChange.Username, AreasImpactadas = selecionarChange.AreasImpactadas, DiaFim = selecionarChange.DiaFim, DiaInicio = selecionarChange.DiaInicio, LocalMudanca = selecionarChange.LocalMudanca, PodeTerRollback = selecionarChange.PodeTerRollback, PrioridadeId = selecionarChange.PrioridadeId, FuncionarioId = selecionarChange.FuncionarioId, Prioridades = itemsPrioridade.ToList() }; return(View(vm)); }
public ActionResult EditarChange(ChangeViewModel model) { model.PrioridadeId = Convert.ToInt32(Request.Form["Prioridades"]); _changeService.UpdateChange(model); return(RedirectToAction("ListarChanges", "Assistencia")); }
public ActionResult Change(string obj) { ChangeViewModel model = new ChangeViewModel(); // данные пользователя List <User> user = new List <User>(); user = account.UsersList(obj); // список всех ролей List <Role> allRoles = RoleConfig.GetAllRoles(); // наполняем модель model.Id = user[0].Id; model.UserName = user[0].UserName; model.Name = user[0].Name; model.LastName = user[0].LastName; model.MiddleName = user[0].MiddleName; model.Email = user[0].Email; model.Roles = null; model.IsActive = user[0].IsActive == 1 ? true : false; model.Superuser = user[0].IsSuperuser == 1 ? true : false; // отмечаем роли, если не Суперпользователь и если есть роли if (!model.Superuser && allRoles.Count() != 0) { // роли List <Role> roles = new List <Role>(); for (var i = 0; i < allRoles.Count(); i++) { // роль Role role = new Role() { Id = allRoles[i].Id, Name = allRoles[i].Name, Type = allRoles[i].Type, Permissions = allRoles[i].Permissions, Selected = false }; // ищем роль в ролях пользователя foreach (var j in user[0].Roles) { // если у пользователя эта роль есть, то отмечаем ее if (allRoles[i].Name == j.Name) { role.Selected = true; break; } } roles.Add(role); // в общий список ролей } // перезаписываем роли в модель model.Roles = roles; } return(PartialView(model)); }
public ViewResult Change(int id) { ChangeViewModel model = new ChangeViewModel(id); return(View(model)); }
public ActionResult UserPwd() { ChangeViewModel viewModel = new ChangeViewModel(); return(View(viewModel)); }