Example #1
0
        public async Task <ActionResult <PollingCentre> > PostPollingCentre(PollingCentre pollingCentre)
        {
            _context.PollingCentres.Add(pollingCentre);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPollingCentre", new { id = pollingCentre.CentreId }, pollingCentre));
        }
Example #2
0
        public async Task <IActionResult> PutPollingCentre(long id, PollingCentre pollingCentre)
        {
            if (id != pollingCentre.CentreId)
            {
                return(BadRequest());
            }

            _context.Entry(pollingCentre).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PollingCentreExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public void PollingCentre_withValid_validations_shouldPass()
        {
            //arrange
            var           u             = new Fixture();
            PollingCentre pollingCentre = u.Create <PollingCentre>();
            //act
            ValidationResultInfo r = pollingCentre.Validate();

            //assert
            Assert.That(r.IsValid, Is.True, "Validation should pass");
        }
        private PollingCentre Create(WardRef ward)
        {
            var pollingCentreEntity = new PollingCentre(Guid.NewGuid())
            {
                Name              = "Democratic".RandStr(),
                Code              = "0011",
                Ward              = ward,
                RegisteredVoters  = 7000,
                Streams           = 25,
                PollingCentreType = PollingCentreType.None,
                Status            = EntityStatus.Active
            };

            return(pollingCentreEntity);
        }
 public void SetAsDeleted(PollingCentre entity)
 {
     throw new NotImplementedException();
 }
 public void SetInactive(PollingCentre entity)
 {
     throw new NotImplementedException();
 }
 public Guid Save(PollingCentre entity, bool?isSync = null)
 {
     Database.InsertOrReplace(entity);
     return(entity.Id);
 }
 public ValidationResultInfo Validate(PollingCentre itemToValidate)
 {
     throw new NotImplementedException();
 }