Exemple #1
0
        public async Task <ActionResult <Growers> > PostGrowers(Growers growers)
        {
            _context.growers.Add(growers);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetGrowers", new { id = growers.id }, growers));
        }
Exemple #2
0
        public async Task <IActionResult> PutGrowers(int id, Growers growers)
        {
            if (id != growers.id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #3
0
 private void CreateDtos()
 {
     for (int i = 0; i < DtoCount; i++)
     {
         var grower = new GrowerDto {
             Uid = Guid.NewGuid(), Name = $"Grower {i}"
         };
         AddFarms(grower);
         Growers.Add(grower);
     }
 }