public SectionsPageView() { int VerticalLine = File.ReadAllLines(@"grids.txt").Where(x => x != "").Count(); byte HorizontalLine = 3; byte sizeG = 2; Array.Resize(ref Resource.name, VerticalLine); Array.Resize(ref Resource.clock, VerticalLine); string[] full = File.ReadAllLines(@"grids.txt", Encoding.Default).Take(VerticalLine).ToArray(); for (int i = 0; i < VerticalLine / sizeG; i++) { for (byte j = 0; j < sizeG; j++) { switch (j) { case 0: Resource.name[i] = full[i * sizeG + j]; break; case 1: Resource.clock[i] = int.Parse(full[i * sizeG + j]); break; } } } int sizeV = (int)Math.Ceiling((decimal)(VerticalLine / 2) / HorizontalLine); //ОКРУГЛЯЕМ В БОЛЬШУЮ СТОРОНУ Math.Ceiling() int sizeVmin = (int)Math.Floor((decimal)(VerticalLine / 2) / HorizontalLine); //ОКРУГЛЯЕМ В МЕНЬШУЮ СТОРОНУ Math.Floor() InitializeComponent(); DataContext = new SectionsViewModel(); InitOldGrid(sizeV, (VerticalLine / 2), sizeVmin, HorizontalLine); }
public ActionResult Edit(SectionsViewModel sections) { if (ModelState.IsValid) { var Mysection = db.Sections.Find(sections.Id); Mysection.SectionName = sections.SectionName; Mysection.Description = sections.Description; Mysection.TotalPoints = sections.TotalPoints; foreach (var item in db.SectionstoTopics) { if (item.SectionsID == sections.Id) { foreach (var item2 in sections.Topics) { if (item.TopicsID == item2.Id) { if (item2.Checked) { } else { db.Entry(item).State = System.Data.Entity.EntityState.Deleted; } } } } } bool A = true; foreach (var item in sections.Topics) { if (item.Checked) { foreach (var item2 in db.SectionstoTopics) { if (item.Id == item2.TopicsID && sections.Id == item2.SectionsID) { A = false; } } if (A) { db.SectionstoTopics.Add(new SectionstoTopics { SectionsID = sections.Id, TopicsID = item.Id }); } A = true; } } db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sections)); }
public SectionTreeControl() { InitializeComponent(); using (var reader = new StringReader(TestXml)) { SectionsViewModel = new SectionsViewModel(Model.Xml.Serializer.Load(reader)); DataContext = SectionsViewModel; SectionsTreeView.ItemsSource = SectionsViewModel.Sections; } }
public JsonResult RepopulateSections() { var col = new List <SectionsViewModel>(); using (SectionsViewModel vm = new SectionsViewModel()) { col = (from p in vm.GetData() select p ).ToList(); var retVal = col.Select(c => new { label = c.SectionName, value = c.SectionID }); return(Json(retVal, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetAllSections(string term) { var col = new List <SectionsViewModel>(); using (SectionsViewModel vm = new SectionsViewModel()) { col = (from p in vm.GetData() where p.SectionName.ToUpper().StartsWith(term.ToUpper().Trim()) select p ).ToList(); var retVal = col.Select(c => new { label = c.SectionName, value = c.SectionID }); return(Json(retVal, JsonRequestBehavior.AllowGet)); } }
public async Task <IActionResult> ApplySettings(SectionsViewModel model) { if (ModelState.IsValid) { SettingsForum settings = await _websiteDB.SettingsForum.FirstAsync(); settings.SubsectionPageSize = model.SubsectionPageSize; settings.TopicPageSize = model.TopicPageSize; _websiteDB.SettingsForum.Update(settings); await _websiteDB.SaveChangesAsync(); } return(RedirectToAction("Sections", "Forum")); }
public async Task <IActionResult> Sections() { SettingsForum settings = await _websiteDB.SettingsForum.FirstAsync(); List <Section> sections = await _websiteDB.Sections.Include(f => f.Subsections).ToListAsync(); SectionsViewModel model = new SectionsViewModel() { SubsectionPageSize = settings.SubsectionPageSize, TopicPageSize = settings.TopicPageSize, Sections = sections }; return(View(model)); }
// GET: Sections/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Sections sections = db.Sections.Find(id); if (sections == null) { return(HttpNotFound()); } var R = from b in db.Topics where b.isActivate == false select new { b.Id, b.TopicName, b.Description, b.TotalPoints, b.ReqDoc, b.DocPoints, Checked = ((from ab in db.SectionstoTopics where (ab.SectionsID == id) & (ab.TopicsID == b.Id) select ab).Count() > 0) }; var Myviewmodel = new SectionsViewModel(); Myviewmodel.Id = id.Value; Myviewmodel.SectionName = sections.SectionName; Myviewmodel.Description = sections.Description; Myviewmodel.TotalPoints = sections.TotalPoints; var Myviewmodel2 = new List <TopicsViewModel>(); foreach (var item in R) { Myviewmodel2.Add(new TopicsViewModel { Id = item.Id, TopicName = item.TopicName, Description = item.Description, TotalPoints = item.TotalPoints, ReqDoc = item.ReqDoc, DocPoints = item.DocPoints, Checked = item.Checked }); } Myviewmodel.Topics = Myviewmodel2; return(View(Myviewmodel)); }
public ActionResult Index(int page = 1) { int pageSize = 15; SectionsViewModel vm = new SectionsViewModel { StaticSections = _rep.StaticSections .OrderBy(x => x.ID) .ToList() .Skip((page - 1) * pageSize) .Take(pageSize), PagingInfo = new PagingInfo { TotalItems = _rep.StaticSections.Count(), CurrentPage = page, ItemsPerPage = pageSize } }; return(View(vm)); }
// GET: Sections public IActionResult Index(int?beginAndEnd, string sectionName, string streetName, int page = 1, SectionsSortState sortOrder = SectionsSortState.BeginAndEndAsc) { int pageSize = 10; IQueryable <Sections> source = _context.Sections.Include(x => x.Street); if (beginAndEnd != 0 && beginAndEnd != null) { source = source.Where(x => x.BeginAndEnd == beginAndEnd); } if (sectionName != null) { source = source.Where(x => x.SectionName.Contains(sectionName)); } if (streetName != null) { source = source.Where(x => x.Street.StreetName.Contains(streetName)); } switch (sortOrder) { case SectionsSortState.BeginAndEndAsc: source = source.OrderBy(x => x.BeginAndEnd); break; case SectionsSortState.BeginAndEndDesc: source = source.OrderByDescending(x => x.BeginAndEnd); break; case SectionsSortState.SectionNameAsc: source = source.OrderBy(x => x.SectionName); break; case SectionsSortState.SectionNameDesc: source = source.OrderByDescending(x => x.SectionName); break; case SectionsSortState.StreetNameAsc: source = source.OrderBy(x => x.Street.StreetName); break; case SectionsSortState.StreetNameDesc: source = source.OrderByDescending(x => x.Street.StreetName); break; default: source = source.OrderBy(x => x.SectionName); break; } var count = source.Count(); IEnumerable <Sections> items = source.Skip((page - 1) * pageSize).Take(pageSize); //var items = source.ToList(); PageViewModel pageView = new PageViewModel(count, page, pageSize); SectionsViewModel ivm = new SectionsViewModel { PageViewModel = pageView, SortViewModel = new SortSectionViewModel(sortOrder), FilterViewModel = new FilterSectionsViewModel(beginAndEnd, sectionName, streetName), Sections = items, Users = _context.User }; return(View(ivm)); }
public ActionResult Index(int page=1) { int pageSize = 15; SectionsViewModel vm = new SectionsViewModel { StaticSections = _rep.StaticSections .OrderBy(x => x.ID) .ToList() .Skip((page - 1) * pageSize) .Take(pageSize), PagingInfo = new PagingInfo { TotalItems = _rep.StaticSections.Count(), CurrentPage = page, ItemsPerPage = pageSize } }; return View(vm); }