Esempio n. 1
0
        // GET: Potions
        public ActionResult Index(int?id)
        {
            if (id < 0 || id == null)
            {
                return(View(new Potions
                {
                    Name = "No Recipie found",
                    Description = "No Recipie found with the id of " + id,
                    navColor = new Color {
                        Description = string.Empty
                    },
                    navEffect = new Effect {
                        Description = string.Empty
                    }
                }));
            }
            PotionManager pManager = new PotionManager();
            var           potion   = pManager.GetPotion(n => n.PotionID == id) ?? new Potions
            {
                Name        = "No Recipie found",
                Description = "No Recipie found with the id of " + id,
                navColor    = new Color {
                    Description = string.Empty
                },
                navEffect = new Effect {
                    Description = string.Empty
                }
            };
            List <Potions> plist = new List <Potions>();

            plist.Add(potion);


            return(View(potion));
        }
Esempio n. 2
0
        public HttpResponseMessage Post([FromBody] int?id)
        {
            try
            {
                var pManager = new PotionManager();

                var potion = id < 0 || id == null
                    ? new Potions
                {
                    Name        = "No Recipie found",
                    Description = "No Recipie found with the id of " + id,
                    navColor    = new Color {
                        Description = string.Empty
                    },
                    navEffect = new Effect {
                        Description = string.Empty
                    }
                }
                    : (pManager.GetPotion(n => n.PotionID == id) ?? new Potions
                {
                    Name = "No Recipie found",
                    Description = "No Recipie found with the id of " + id,
                    navColor = new Color {
                        Description = string.Empty
                    },
                    navEffect = new Effect {
                        Description = string.Empty
                    }
                });

                Mapper.CreateMap <Potions, PotionResponse>();
                var response = Mapper.Map <Potions, PotionResponse>(potion);

                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception exception)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, exception.Message));
            }
        }
Esempio n. 3
0
        public ActionResult Next(int?id)
        {
            if (id < 0 || id == null)
            {
                return(Json(new Potions
                {
                    Name = "No Recipie found",
                    Description = "No Recipie found with the id of " + id,
                    navColor = new Color {
                        Description = string.Empty
                    },
                    navEffect = new Effect {
                        Description = string.Empty
                    }
                }));
            }
            PotionManager pManager = new PotionManager();
            var           potion   = pManager.GetPotion(n => n.PotionID == id) ?? new Potions
            {
                Name        = "No Recipie found",
                Description = "No Recipie found with the id of " + id,
                navColor    = new Color {
                    Description = string.Empty
                },
                navEffect = new Effect {
                    Description = string.Empty
                }
            };
            List <Potions> plist = new List <Potions>();

            plist.Add(potion);

            string json = JsonConvert.SerializeObject(potion, Formatting.Indented);

            return(Json(json));
        }