Ejemplo n.º 1
0
        async Task ExecuteLoadElephantsCommand()
        {
            IsBusy = true;

            try
            {
                Elephants.Clear();
                var elephants = await Data.GetElephantsAsync(true);

                foreach (var elephant in elephants)
                {
                    if (elephant.Name != null)
                    {
                        elephant.Image = (elephant.Image != null && elephant.Image != "") ? elephant.Image : "elephant_default";
                        Elephants.Add(elephant);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
 public IActionResult Post([FromBody] Elephants elephant)
 {
     if (!ElephantExists(elephant.Id))
     {
         _dbList.Add(elephant);
         return(CreatedAtAction("Get", new { id = elephant.Id }, elephant));
     }
     else
     {
         return(NotFound(new { message = "Id is duplicate" }));
     }
 }
        public IActionResult Put(int id, [FromBody] Elephants newElephant)
        {
            if (id != newElephant.Id)
            {
                return(BadRequest());
            }
            var currentElephant = GetElephant(id);

            if (currentElephant != null)
            {
                currentElephant.Name    = newElephant.Name;
                currentElephant.Species = newElephant.Species;
            }
            else
            {
                return(NotFound());
            }
            return(NoContent());
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            Elephants e = new Elephants();

            e.ShowInfo();
        }