// Filter Function public IActionResult FilterBurials(int locationfilter, string genderfilter, decimal depthfilter, int pagenumber = 1) { // get filteted list IEnumerable <Burial> burials = _context.Burials. Where(b => (genderfilter == null || genderfilter == b.Sex) & (depthfilter == 0 || b.Depth < depthfilter) & (locationfilter == -1 || locationfilter == 0 || b.BurialLocationId == locationfilter) ) .Include(b => b.BurialLocation); // fcount full set then filter int TotalBurialsInt = burials.Count(); burials = burials.OrderBy(b => b.BurialID).Skip((pagenumber - 1) * pageSize).Take(pageSize); // get stored key values AddSiteViewModel FilteredBurialList = new AddSiteViewModel() { // get burials Burials = burials, PaginationInfo = new PageNumberingInfo { CurrentPage = pagenumber, NumItemsPerPage = pageSize, // either uses all books or just books in cat TotalNumItems = TotalBurialsInt }, }; return(View("ViewSites", FilteredBurialList)); }
public async Task <ActionResult> Edit(AddSiteViewModel model) { try { if (model.SiteName != null) { string domainId = DomainSession.GetContextDomain(this.HttpContext); iotDomain d = Icont.Domains.First(dm => dm.DomainName.Equals(domainId)); Location loc = d.Locations.First(l => l.Id == d.Id); if (loc != null) { model.site.siteLocation = loc; model.site.Domain = d; Icont.Sites.Add(model.site); Icont.SaveChanges(); var stored = Icont.Sites.First(s => s.SiteName.Equals(model.site.SiteName)); model.Result = StatusResponseGenerator.GetStatusResponseResultForReturnParam(stored); } return(View(model)); } else { model.Result = StatusResponseGenerator.GetAlertPanelWithMsgAndStat("Error.", RequestStatus.Failure); } } catch (Exception e) { model.Result = StatusResponseGenerator.GetAlertPanelWithMsgAndStat("Error.", RequestStatus.Failure); } return(View(model)); }
public AddSiteView(AddSiteViewModel viewModel, IEventAggregator eventAggregator) { InitializeComponent(); this.eventAggregator = eventAggregator; this.DataContext = viewModel; viewModel.PropertyChanged += viewModel_OnPropertyChanged; }
public IActionResult AddSite() { AddSiteViewModel addSiteViewModel = new AddSiteViewModel(); List <SystemCode> myList = _systemCodeRepository.GetAllSystemCodes().ToList(); addSiteViewModel.SystemCodes = myList; return(View(addSiteViewModel)); }
public ActionResult Add(int id) { var viewModel = new AddSiteViewModel { OrganisationId = id }; return(View(viewModel)); }
public IActionResult EditSite(Guid Id, String Code)// { AddSiteViewModel addSiteViewModel = new AddSiteViewModel(); List <SystemCode> myList = _systemCodeRepository.GetAllSystemCodes().ToList(); addSiteViewModel.SystemCodes = myList; var site = _siteRepository.GetSiteById(Id); addSiteViewModel.Site = site; if (site == null) { NotFound(); } return(View(addSiteViewModel)); }
public ActionResult Add() { try { string domainId = DomainSession.GetContextDomain(this.HttpContext); iotDomain d = Icont.Domains.First(dm => dm.DomainName.Equals(domainId)); List <Location> locations = d.Locations.ToList(); AddSiteViewModel model = new AddSiteViewModel(locations); return(View(model)); } catch (Exception e) { return(View()); } }
public async Task <SimpleResult> AddSite(AddSiteViewModel input) { try { var site = await _context.Sites.FindAsync(input.Id); SimpleResult result; var poco = new SitePoco { Name = input.Name, Latitude = input.LatLng.Lat, Longitude = input.LatLng.Lng, Address = input.Address, Abbr = input.Abbr }; if (site != null) { site.Latitude = input.LatLng.Lat; site.Longitude = input.LatLng.Lng; site.Name = input.Name; site.Abbr = input.Abbr; site.Address = input.Address; _context.Entry(site).State = EntityState.Modified; await _context.SaveChangesAsync(); result = new SimpleResult { IsSuccess = true }; } else { result = await _domain.AddSite(poco); } return(result); } catch { return(new SimpleResult { IsSuccess = false }); } }
public IActionResult AddSite(string filterer, int pagenumber = 1) { AddSiteViewModel BurialList = new AddSiteViewModel() { // get burials Burials = _context.Burials.Include(b => b.BurialLocation) .OrderBy(b => b.BurialID).Skip((pagenumber - 1) * pageSize).Take(pageSize), PaginationInfo = new PageNumberingInfo { CurrentPage = pagenumber, NumItemsPerPage = pageSize, // either uses all books or just books in cat TotalNumItems = filterer == null?_context.Burials.Count() : _context.Burials.Where(b => b.Category == filterer).Count() } }; return(View(BurialList)); }
// view site public IActionResult ViewSites(int pagenumber = 1) { IEnumerable <Burial> burials = _context.Burials.Include(b => b.BurialLocation); int totalBurials = burials.Count(); AddSiteViewModel BurialList = new AddSiteViewModel() { // get burials Burials = _context.Burials.Include(b => b.BurialLocation) .OrderBy(b => b.BurialID).Skip((pagenumber - 1) * pageSize).Take(pageSize), PaginationInfo = new PageNumberingInfo { CurrentPage = pagenumber, NumItemsPerPage = pageSize, // either uses all books or just books in cat TotalNumItems = totalBurials } }; return(View(BurialList)); }
public ActionResult Add(AddSiteViewModel model) { if (!ModelState.IsValid) { return(View(model)); } //Check is there another site with the same name if (this.siteService.IsExist(model.Name)) { this.ModelState.AddModelError("", SiteTr.ExistSite); return(View(model)); } this.siteService.Add(new Site { Id = model.Id, Name = model.Name, OrganisationId = model.OrganisationId }); return(Redirect("/Admin/Organisation/Details/" + model.OrganisationId)); }
// Filter Burial List/////////////////////////////////////////////// // checks user in controller public IActionResult FilterBurials(string customfilter, string customfiltervalue, int locationfilter, string genderfilter, decimal depthfilter, int pagenumber = 1) { // get filteted from initial filters list IEnumerable <Burial> initburials = _context.Burials. Where(b => (genderfilter == null || genderfilter == b.Sex) & (depthfilter == 0 || b.Depth < depthfilter) & (locationfilter == -1 || locationfilter == 0 || b.BurialLocationId == locationfilter) ); // fcount full set then filter // needed to subtract to get pagination info but optomize speeds int TotalBurialsInt = initburials.Count(); List <Burial> burials_to_pass = new List <Burial>(); // big custom filter guy if (customfilter != "None" & customfilter != null) { foreach (Burial burial in initburials) { foreach (PropertyInfo prop in burial.GetType().GetProperties()) { if (prop.Name == customfilter) { var comparevalue = prop.GetValue(burial); if (comparevalue is string) { if (comparevalue.ToString().ToLower().Contains(customfiltervalue.ToLower()) == true) { burials_to_pass.Add(burial); } } } } } // get TotalBurialsInt = burials_to_pass.Count(); burials_to_pass = burials_to_pass.OrderBy(b => b.BurialID).Skip((pagenumber - 1) * pageSize).Take(pageSize).ToList(); } else { burials_to_pass = initburials.ToList(); burials_to_pass = burials_to_pass.OrderBy(b => b.BurialID).Skip((pagenumber - 1) * pageSize).Take(pageSize).ToList(); } // get stored key values AddSiteViewModel FilteredBurialList = new AddSiteViewModel() { // get burials Burials = burials_to_pass, PaginationInfo = new PageNumberingInfo { CurrentPage = pagenumber, NumItemsPerPage = pageSize, // either uses all books or just books in cat TotalNumItems = TotalBurialsInt }, }; if (User.Identity.IsAuthenticated) { return(View("AddSite", FilteredBurialList)); } return(View("ViewSites", FilteredBurialList)); }
public async Task <JsonResult> AddSite([FromBody] AddSiteViewModel input) { var result = await _site.AddSite(input); return(await GenerateResult(result, _userSettings)); }