コード例 #1
0
        // 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));
        }
コード例 #2
0
 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));
 }
コード例 #3
0
    public AddSiteView(AddSiteViewModel viewModel, IEventAggregator eventAggregator)
    {
      InitializeComponent();

      this.eventAggregator = eventAggregator;
      this.DataContext = viewModel;
      viewModel.PropertyChanged += viewModel_OnPropertyChanged;
    }
コード例 #4
0
        public IActionResult AddSite()
        {
            AddSiteViewModel  addSiteViewModel = new AddSiteViewModel();
            List <SystemCode> myList           = _systemCodeRepository.GetAllSystemCodes().ToList();

            addSiteViewModel.SystemCodes = myList;
            return(View(addSiteViewModel));
        }
コード例 #5
0
        public ActionResult Add(int id)
        {
            var viewModel = new AddSiteViewModel
            {
                OrganisationId = id
            };

            return(View(viewModel));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
 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());
     }
 }
コード例 #8
0
ファイル: Site.cs プロジェクト: AlistairB99124/Xataris
        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
                });
            }
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        // 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));
        }
コード例 #11
0
        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));
        }
コード例 #12
0
        // 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));
        }
コード例 #13
0
        public async Task <JsonResult> AddSite([FromBody] AddSiteViewModel input)
        {
            var result = await _site.AddSite(input);

            return(await GenerateResult(result, _userSettings));
        }