public ActionResult EditGroup(string id) { string commandText = "SELECT * FROM[dbo].[Group] where ID = '" + id + "';"; List <Group> groups = new List <Group>(); GroupsViewModel model = new GroupsViewModel(); using (SqlConnection dbConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) using (SqlCommand dbCommand = new SqlCommand(commandText, dbConnection)) { dbCommand.CommandType = System.Data.CommandType.Text; dbConnection.Open(); SqlDataReader reader = dbCommand.ExecuteReader(); while (reader.Read()) { groups.Add(new Group() { ID = (string)reader["ID"], GroupName = (string)reader["GroupName"], GroupDesc = (string)reader["GroupDesc"], GroupImage = (string)reader["GroupImage"] }); } dbConnection.Close(); } ViewData["CurrentGroup"] = groups; ViewBag.ReturnUrl = id; return(View()); }
// GET: Groups/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblGroups tblGroups = db.tblGroups.Find(id); if (tblGroups == null) { return(HttpNotFound()); } GroupsViewModel groupsViewModel = new GroupsViewModel(); ImplementedMethods implementedMethods = new ImplementedMethods(); groupsViewModel.Name = tblGroups.Name; groupsViewModel.PK_Id = tblGroups.PK_Id; groupsViewModel.Actions = tblGroups.tblGroupActions.Select(s => new ActionsViewModel { PK_Id = s.PK_Id, Name = s.ActionName }).ToList(); ViewBag.AvailableActions = implementedMethods.ActiveMethods.Where(t => !db.tblGroupActions.Any(k => k.FK_Group == id && k.ActionName == t)).Select(s => new SelectListItem { Value = s, Text = s }).ToList(); return(View(groupsViewModel)); }
// GET: MyGroups public ActionResult Index() { _context = new ApplicationDbContext(); //UsersGroups curUser = _context.Users User.Identity.GetUserId string curUserID = User.Identity.GetUserId(); List <Groups> groupsList = (from gr in _context.Groups.ToList() from ug in _context.UsersGroups.ToList() where gr.Id == ug.GroupId && ug.UserId == User.Identity.GetUserId() select gr).ToList(); List <Groups> gWhereUserOwner = (from gr in _context.Groups.ToList() where gr.Owner == User.Identity.GetUserId() select gr).ToList(); groupsList.AddRange(gWhereUserOwner); //_context.Groups.Select(g => g).ToList<Groups>(); List <ApplicationUser> ownersList = new List <ApplicationUser>(); foreach (String owner_id in groupsList.Select(g => g.Owner).ToList()) { if (_context.Users.FirstOrDefault(o => o.Id == owner_id) != null) { ownersList.Add(_context.Users.FirstOrDefault(o => o.Id == owner_id)); } } var viewModel = new GroupsViewModel { groups = groupsList, owners = ownersList }; return(View(viewModel)); }
public PartialViewResult _GroupInformation(int id) { var userId = User.Identity.GetUserId(); var com = new GroupCommunication(); var group = com.GetGroup(id); var member = com.GetGroupMember(userId, id); var name = group.Creator.FirstName + " " + group.Creator.LastName; var model = new GroupsViewModel { GroupName = group.Name, Administrator = name, Description = group.Description, TimeCreated = group.TimeCreated, MemberShip = member.MembershipTime }; if (group.Creator.UserName.Equals(User.Identity.GetUserName())) { model.MemberStatus = "Administrator"; } else { model.MemberStatus = "User"; } return(PartialView("_GroupInformation", model)); }
public PaginaDeResultado <GroupsViewModel> GetAllGroups(int paginaNumero, int paginaTamanho) { var model = new GroupsViewModel(); try { int ExcludeRecords = (paginaTamanho * paginaNumero) - paginaNumero; List <GroupsViewModel> detalheList = new List <GroupsViewModel>(); var modelList = _unitOfWork.GenericRepository <Groups>().GetAll() .Skip(ExcludeRecords).Take(paginaTamanho).ToList(); var contaTotal = _unitOfWork.GenericRepository <Groups>().GetAll().ToList(); detalheList = GroupListInfo(modelList); if (detalheList != null) { model.GroupList = detalheList; model.ContaTotal = contaTotal.Count(); } } catch (Exception ex) { _ILogger.LogError(ex.Message); } var resultado = new PaginaDeResultado <GroupsViewModel> { Data = model.GroupList, TotalItems = model.ContaTotal, PaginaNumero = paginaNumero, PaginaTamanho = paginaTamanho, }; return(resultado); }
public App() { var waypointsService = new WaypointsService(); var groupsService = new GroupsService(waypointsService); GeoLayoutBuildingService = new GeoLayoutBuildingService(waypointsService, groupsService); SettingsService = new SettingsService(); var importService = new ImportService( new List <IGeoImporter>(new [] { new GpxImporter() }), new MultiFileDialogService(Current.MainWindow), waypointsService); var exportService = new ExportService( new List <IGeoExporter>(new [] { new GpxExporter() }), new SaveFileDialogService(Current.MainWindow), waypointsService); MainViewModel = new MainViewModel(importService, exportService, waypointsService, groupsService, GeoLayoutBuildingService); MapViewModel = new MapViewModel(waypointsService, groupsService, GeoLayoutBuildingService); GroupsViewModel = new GroupsViewModel(groupsService, waypointsService); }
public void CreateGroup(GroupsViewModel model) { string named = model.Groups.GroupName; string desc = model.Groups.GroupDesc; string image = model.Groups.GroupImage; string idd = "" + Guid.NewGuid(); Boolean peekaboo = true; string commandText = "INSERT INTO [dbo].[Group] (Id, GroupName, GroupDesc, GroupImage,Owner_Id) VALUES ('" + idd + "','" + named + "','" + desc + "','" + image + "','" + User.Identity.GetUserId() + "');"; string commandText2 = "INSERT INTO [dbo].[UserGroup] (User_Id, Group_ID) VALUES ('" + User.Identity.GetUserId() + "' , '" + idd + "');"; using (SqlConnection dbConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) using (SqlCommand dbCommand = new SqlCommand(commandText, dbConnection)) { dbCommand.CommandType = System.Data.CommandType.Text; dbConnection.Open(); try { dbCommand.ExecuteNonQuery(); } catch (Exception o) { peekaboo = false; Debug.WriteLine(o.StackTrace); } if (peekaboo == true) { SqlCommand dbCommand2 = new SqlCommand(commandText2, dbConnection); dbCommand2.ExecuteNonQuery(); } else { } dbConnection.Close(); } }
public IActionResult Groups() { var users = userManager.Users .OrderBy(x => x.ShortName) .ToList(); var groups = groupService.GetGroups(); var mappedUsers = mapper.Map <List <UserDetailsViewModel> >(users); var currentUserId = userManager.GetUserId(User); var isAdmin = User.IsInRole(Constants.ROLE_ADMIN); groupService.ArrangeTeamBets(groups, mappedUsers, currentUserId, isAdmin); var roundPoints = groupService.GetRoundResults(groups, users.Count); var bonusPoints = roundService.GetBonusResults(roundPoints); var totalPoints = roundService.GetTotalResults(roundPoints, bonusPoints); var model = new GroupsViewModel() { Users = mappedUsers, Groups = groups, RoundPoints = roundPoints, BonusPoints = bonusPoints, TotalPoints = totalPoints }; return(View(model)); }
public GroupsPage() { InitializeComponent(); var viewModel = new GroupsViewModel(); BindingContext = viewModel; }
public GroupPage() { InitializeComponent(); BindingContext = groupsViewModel = new GroupsViewModel(); }
public GroupsPage() { InitializeComponent(); viewModel = new GroupsViewModel(); DataContext = viewModel; servicesPage = this; }
public bool SetGroupIdToEstudante(GroupsViewModel vm) { try { foreach (var item in vm.EstudanteCheckList) { var estudante = _unitOfWork.GenericRepository <Estudante>().GetByID(item.Id); if (item.Selecione) { estudante.GroupsId = vm.Id; _unitOfWork.GenericRepository <Estudante>().Update(estudante); } else { if (estudante.GroupsId == vm.Id) { estudante.GroupsId = null; } } _unitOfWork.Save(); return(true); } } catch (Exception ex) { _ILogger.LogError(ex.Message); } return(false); }
public ActionResult Edit(GroupsViewModel group) { if (ModelState.IsValid) { var reqGroup = db.Groups.Find(group.Id); reqGroup.Name = group.Name; foreach (var cg in db.Client_Groups) { if (cg.GroupId == group.Id) { db.Entry(cg).State = EntityState.Deleted; } } foreach (var c in group.Clients) { if (c.Checked) { db.Client_Groups.Add(new Client_Group { ClientId = c.Id, GroupId = group.Id }); } } db.SaveChanges(); return(RedirectToAction("Index")); } return(View(group)); }
// GET: Groups public IActionResult Index(int page = 1) { PageViewModel pageViewModel = new PageViewModel(groupDAO.Count(), page, 10); GroupsViewModel model = new GroupsViewModel(groupDAO.GetList(page), pageViewModel); return(View(model)); }
public ActionResult GroupDitail(int id) { _context = new ApplicationDbContext(); Groups group = _context.Groups.FirstOrDefault(gr => gr.Id == id); if (group == null) { return(RedirectToAction("Index", "Group")); } ApplicationUser curOwner = _context.Users.FirstOrDefault(o => o.Id == group.Owner); List <ApplicationUser> users = _context.Users.Select(u => u).ToList(); var usersGroup = (from u in _context.Users.ToList() from gu in _context.UsersGroups.ToList() where gu.GroupId == @group.Id && gu.UserId == u.Id select u).ToList(); var groupsView = new GroupsViewModel { group = group, owners = users, curOwner = curOwner, usersOfCurrentGroups = usersGroup, }; groupsView.SelectedIDArray = groupsView.usersOfCurrentGroups.Select(u => u.Id).ToArray(); return(View(groupsView)); }
public HttpResponseMessage Post([FromBody] GroupsViewModel group) { if (ModelState.IsValid) { int userId = Convert.ToInt32(this.User.FindFirstValue(ClaimTypes.Name)); int coorid = _teacher.GetTeacherId(userId); var tempEnrol = AutoMapper.Mapper.Map <Groups>(group); tempEnrol.createdBy = coorid; _group.InsertGroup(tempEnrol); var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.OK }; return(response); } else { var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest }; return(response); } }
public ActionResult Save(GroupsViewModel group, HttpPostedFileBase File) { if (!ModelState.IsValid) { return(View("Edit", group)); } if (group.Groups.Id == 0) // New group { // Saving uploaded image to folder //string fileName = Path.GetFileNameWithoutExtension(image.FileName); ////string fName = Path.GetFileName(image.FileName); //string extension = Path.GetExtension(image.FileName); //fileName = fileName + extension; //var fileNamePath = Path.Combine(Server.MapPath("~/Content/Images"), fileName); //image.SaveAs(fileNamePath); //group.GroupImage = fileName; group.Groups.DateCreated = DateTime.Now; using (var binaryReader = new BinaryReader(File.InputStream)) //convert image to binary and save group.Groups.GroupImage = binaryReader.ReadBytes(File.ContentLength); _context.Groups.Add(group.Groups); } // For editing existing group else { var groupInDb = _context.Groups.SingleOrDefault(g => g.Id == group.Groups.Id); if (File == null) { groupInDb.GroupImage = groupInDb.GroupImage; } if (File != null) { using (var binaryReader = new BinaryReader(File.InputStream)) //convert image to binary and save groupInDb.GroupImage = binaryReader.ReadBytes(File.ContentLength); } groupInDb.Name = group.Groups.Name; groupInDb.About = group.Groups.About; groupInDb.MeetingPoint = group.Groups.MeetingPoint; groupInDb.TimeOfMeeting = group.Groups.TimeOfMeeting; groupInDb.GroupCreator = group.Groups.GroupCreator; groupInDb.GroupTypesId = group.Groups.GroupTypesId; groupInDb.EntryTypesId = group.Groups.EntryTypesId; groupInDb.InterestsId = group.Groups.InterestsId; //group.Groups.GroupImage = new byte[File.ContentLength]; //File.InputStream.Read(group.Groups.GroupImage, 0, File.ContentLength); } _context.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /Groups/EditMode // Displays all the groups of the clan in edit mode public ActionResult EditMode() { int?clanId = ClanManager.GetClanId(User.Identity.GetUserId()); GroupsViewModel model = new GroupsViewModel((int)clanId, editMode: true); return(View("Index", model)); }
public ActionResult Submit(GroupsViewModel groups) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); try { if (ModelState.IsValid) { if (groups.Id <= 0) { groups.TenantId = tenant.TenantId; groups.DateCreated = DateTime.UtcNow; groups.DateUpdated = DateTime.UtcNow; groups.CreatedBy = user.UserId; groups.UpdatedBy = user.UserId; //insert groups.Id = _groupsServices.Insert(Mapper.Map <Groups>(groups), CurrentUserId); ViewBag.Message = $"Successfully Added on {DateTime.Now}."; } else { //update Groups newGroup = _groupsServices.GetByGroupsId(groups.Id); //groups.TenantId = Tenant.TenantId; newGroup.GroupName = groups.GroupName; newGroup.DateUpdated = DateTime.UtcNow; newGroup.UpdatedBy = user.UserId; _groupsServices.Update(Mapper.Map <Groups>(newGroup), CurrentUserId); ViewBag.Message = $"Successfully Updated on {DateTime.Now}."; } return(RedirectToAction("Index", new { message = ViewBag.Message })); } else //ModelState.IsValid is not valid { return(View("_CreateEdit", Mapper.Map(_groupsServices.GetByGroupsId(groups.Id), new GroupsViewModel()))); } } catch (Exception e) { //log exception var err = e.Message; return(View("_ErrorResult")); } }
public async Task <ActionResult> SaveGroup(GroupsViewModel group, HttpPostedFileBase File) { if (!ModelState.IsValid) { var viewModel = new GroupsViewModel() { Groups = group.Groups, Interests = await _context.Interests.ToListAsync(), GroupTypes = await _context.GroupTypes.ToListAsync(), EntryTypes = await _context.EntryTypes.ToListAsync() }; ViewBag.user = await _context.Users.SingleOrDefaultAsync(m => m.Id == group.Groups.ApplicationUserId); return(View("CreateGroup", viewModel)); } if (group.Groups.Id == 0) // New group { group.Groups.DateCreated = DateTime.Now; using (var binaryReader = new BinaryReader(File.InputStream)) //convert image to binary and save group.Groups.GroupImage = binaryReader.ReadBytes(File.ContentLength); _context.Groups.Add(group.Groups); } // For editing existing group else { var groupInDb = await _context.Groups.SingleOrDefaultAsync(g => g.Id == group.Groups.Id); if (File == null) { groupInDb.GroupImage = groupInDb.GroupImage; } if (File != null) { using (var binaryReader = new BinaryReader(File.InputStream)) //convert image to binary and save groupInDb.GroupImage = binaryReader.ReadBytes(File.ContentLength); } groupInDb.Name = group.Groups.Name; groupInDb.About = group.Groups.About; groupInDb.MeetingPoint = group.Groups.MeetingPoint; groupInDb.TimeOfMeeting = group.Groups.TimeOfMeeting; groupInDb.GroupCreator = group.Groups.GroupCreator; groupInDb.GroupTypesId = group.Groups.GroupTypesId; groupInDb.EntryTypesId = group.Groups.EntryTypesId; groupInDb.InterestsId = group.Groups.InterestsId; } await _context.SaveChangesAsync(); return(RedirectToAction("Index")); }
public ActionResult Create() { _context = new ApplicationDbContext(); var viewModel = new GroupsViewModel { group = new Groups(), owners = _context.Users.Select(c => c).ToList() }; return(View(viewModel)); }
public ActionResult Groups() { GroupsViewModel viewModel = new GroupsViewModel() { Groups = _repository.GetGroups().ToList() }; return(View(viewModel)); }
private void Init() { FriendsFilter = new FriendsViewModel(); GroupsFilter = new GroupsViewModel(); AudioPlayerVM = new AudioPlayerViewModel(); ShowMyAudiosCommand = new DelegateCommand(() => AudioPlayerVM.ShowMyAudios()); SelectedFilter = AudioFilters.My; AudioPlayerVM.OnLoadingStateChanged += audioPlayerVM_OnLoadingStateChanged; }
public GroupsPage(string ztdId) { InitializeComponent(); BindingContext = viewModel = new GroupsViewModel(); this.ztdid = ztdId; Completed = new System.Threading.Tasks.TaskCompletionSource <bool>(); }
public GroupsView() { InitializeComponent(); BindingContext = viewModel = new GroupsViewModel(this); managerMode = Settings.OrganizerMode; ToolbarItems.Add(new ToolbarItem { StyleId = "Settings", Icon = "ic_action_settings.png", Text = "Settings", Order = ToolbarItemOrder.Primary, Command = viewModel.GoToAboutCommand }); GroupsList.ItemSelected += (sender, e) => { var selected = GroupsList.SelectedItem as Group; if (selected == null) { return; } viewModel.GoToGroupCommand.Execute(selected); GroupsList.SelectedItem = null; }; GroupsList.ItemAppearing += (sender, e) => { if (viewModel.IsBusy || viewModel.Groups.Count == 0) { return; } //hit bottom! if (((Group)e.Item).Id == viewModel.Groups[viewModel.Groups.Count - 1].Id) { viewModel.LoadMoreCommand.Execute(null); } }; //ensure after first load that we scroll to the top. /*viewModel.FinishedFirstLoad = (index) => * { * if(viewModel.Groups.Count == 0) * return; * * Device.StartTimer(TimeSpan.FromMilliseconds(100), ()=> * { * Device.BeginInvokeOnMainThread(() => * GroupsList.ScrollTo(viewModel.Groups[index], ScrollToPosition.MakeVisible, false)); * * return false; * }); * };*/ }
public IActionResult Detalhes(GroupsViewModel groupsViewModel) { bool resultado = _estudanteService.SetGroupIdToEstudante(groupsViewModel); if (resultado) { return(RedirectToAction("Detalhes", new { groupId = groupsViewModel.Id })); } return(View(groupsViewModel)); }
public DetailerView() { InitializeComponent(); BindingContext = viewModel = new GroupsViewModel(); //var media = viewModel.GetAnnouncement(); //foreach(var med in media) //{ // listView.Children.Add(template); //} }
protected UnitsContainer(IUnityContainer container) : base(container) { DetailsViewModel = container.Resolve <TDetailsViewModel>(); GroupsViewModel = container.Resolve <TGroupsViewModel>(); SaveCommand = new DelegateLogCommand( () => { //отписка от событий изменения строк с оборудованием this.GroupsViewModel.GroupChanged -= OnGroupChanged; GroupsViewModel.AcceptChanges(); //добавляем сущность, если ее не существовало if (UnitOfWork.Repository <TModel>().GetById(DetailsViewModel.Item.Model.Id) == null) { UnitOfWork.Repository <TModel>().Add(DetailsViewModel.Item.Model); } DetailsViewModel.Item.AcceptChanges(); Container.Resolve <IEventAggregator>().GetEvent <TAfterSaveModelEvent>().Publish(DetailsViewModel.Item.Model); //сохраняем try { UnitOfWork.SaveChanges(); } catch (DbUpdateConcurrencyException e) { Container.Resolve <IMessageService>().ShowOkMessageDialog("Ошибка при сохранении", e.PrintAllExceptions()); } //регистрация на события изменения строк с оборудованием this.GroupsViewModel.GroupChanged += OnGroupChanged; SaveCommand.RaiseCanExecuteChanged(); }, () => { //все сущности должны быть валидны if (!GroupsViewModel.IsValid || !DetailsViewModel.Item.IsValid) { return(false); } //какая-то сущность должна быть изменена return(DetailsViewModel.Item.IsChanged || GroupsViewModel.IsChanged); }); RoundUpCommand = new DelegateLogCommand( () => { GroupsViewModel.RoundUpGroupsCosts(RoundUpAccuracy); }); }
public IActionResult Index() { var groupContext = db.Groups.Include(p => p.Listener).Include(p => p.Course); GroupsViewModel groups = new GroupsViewModel { Groups = groupContext.ToList(), GroupViewModel = _groups }; return(View(groups)); }
public SelectGroupTypesCommand(NavigationStore navigationStore, NotificationStore notificationStore, ScheduleManager scheduleManager, TimeTableDto timeTableData) { var groupViewModel = new GroupsViewModel(scheduleManager, navigationStore, notificationStore); groupViewModel.SetTimeTableData(timeTableData); _navigationService = new NavigationService <GroupsViewModel>(navigationStore, groupViewModel); }
public GroupAutoCompleteControl() { InitializeComponent(); this.Loaded += OnLoaded; var viewModel = new GroupsViewModel(); viewModel.SelectedGroupChanged += OnSelectedGroupChanged; viewModel.OnCreateNewGroupClicked += OnCreateNewGroup; this.DataContext = viewModel; GroupNameTextBox.PreviewMouseLeftButtonDown += OnTextBoxMouseLeftButtonDown; GroupNameTextBox.PreviewMouseLeftButtonUp += OnTextBoxMouseLeftButtonUp; }