Example #1
0
        public async Task <IActionResult> UpdatePSCommissions(Guid eid, Guid id, PollingStationCommissionUI commission)
        {
            var q  = from c in _context.PollingStationCommission where c.ElectionFk == eid && c.Id == id select c;
            var pc = await q.FirstAsync();

            commission.UpdatePollingStationCommission(pc);
            await _context.SaveChangesAsync();

            return(Ok());
        }
Example #2
0
        public async Task <List <PollingStationCommissionUI> > NewPSCommissions(Guid id, PollingStationCommissionUI commission)
        {
            var com = new PollingStationCommission();

            com.Id        = Guid.NewGuid();
            commission.Id = com.Id;
            commission.UpdatePollingStationCommission(com);
            _context.PollingStationCommission.Add(com);
            await _context.SaveChangesAsync();

            var q = from c in _context.PollingStationCommission where c.ElectionFk == id select c;

            return((await q.ToListAsync()).ConvertAll(c => new PollingStationCommissionUI(c)));
        }
Example #3
0
        public async Task <IActionResult> AddPSCommission(PollingStationCommissionUI comm, Guid?presidentFK)
        {
            var c = new PollingStationCommission();

            c.Id = Guid.NewGuid();
            comm.UpdatePollingStationCommission(c);
            _context.PollingStationCommission.Add(c);

            await _context.SaveChangesAsync();

            if (presidentFK.HasValue)
            {
                var memb = new PollingStationCommissioner();
                memb.Id       = Guid.NewGuid();
                memb.PersonFk = presidentFK.Value;
                memb.PollingStationCommissionFk = c.Id;

                c.PresidentFk = memb.Id;
                _context.PollingStationCommissioner.Add(memb);
                await _context.SaveChangesAsync();
            }
            return(RedirectToAction("EditPollingStations", new { id = comm.ElectionFk }));
        }