Пример #1
0
        public IHttpActionResult findTechnique(int id)
        {
            //Find the data
            TechniqueDto technique = getTechniqueDto(id);

            //if not found, return 404 status code.
            if (technique == null)
            {
                return(NotFound());
            }

            //pass along data as 200 status code OK response
            return(Ok(technique));
        }
Пример #2
0
        // GET: Technique/Details/5
        public ActionResult Details(int id)
        {
            string url = "TechniqueData/findTechnique/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                TechniqueDto technique = response.Content.ReadAsAsync <TechniqueDto>().Result;
                return(View(technique));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Пример #3
0
        private TechniqueDto getTechniqueDto(int id)
        {
            Technique technique = db.techniques.Find(id);

            if (technique == null)
            {
                return(null);
            }
            //put into a 'friendly object format'
            TechniqueDto techniqueDto = new TechniqueDto {
                techniqueId   = technique.techniqueId,
                techniqueName = technique.techniqueName
            };

            return(techniqueDto);
        }
Пример #4
0
        public ActionResult DeleteConfirm(int id)
        {
            string url = "TechniqueData/findTechnique/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            //Can catch the status code (200 OK, 301 REDIRECT), etc.
            //Debug.WriteLine(response.StatusCode);
            if (response.IsSuccessStatusCode)
            {
                //Put data into player data transfer object
                TechniqueDto techniqueDto = response.Content.ReadAsAsync <TechniqueDto>().Result;
                return(View(techniqueDto));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Пример #5
0
        // GET: api/TechniquesData/getTechniques
        // Authorize annotation will block requests unless user is authorized
        // authorization process checks for valid cookies in request
        //[Authorize]
        public IEnumerable <TechniqueDto> getTechniques()
        {
            List <Technique>    techniques    = db.techniques.ToList();
            List <TechniqueDto> techniqueDtos = new List <TechniqueDto> {
            };

            //Here you can choose which information is exposed to the API
            foreach (var technique in techniques)
            {
                TechniqueDto techniqueDto = new TechniqueDto {
                    techniqueId   = technique.techniqueId,
                    techniqueName = technique.techniqueName
                };
                techniqueDtos.Add(techniqueDto);
            }

            return(techniqueDtos);
        }