コード例 #1
0
        public async Task <int> CreateVotation(Votation votation)
        {
            votation.VotationStatus = true;
            _context.Add(votation);

            var result = await _context.SaveChangesAsync();

            if (result == 0)
            {
                return(0);
            }

            return(votation.Id);
        }
コード例 #2
0
        public async Task <bool> UpdateVotation(Votation votation)
        {
            var votationToEdit = _context.Votations.Find(votation.Id);

            if (votationToEdit == null)
            {
                return(false);
            }

            votationToEdit.VotationDescription = votation.VotationDescription;

            _context.Votations.Update(votationToEdit);

            var result = await _context.SaveChangesAsync();

            if (result != 0)
            {
                return(true);
            }

            return(false);
        }