Example #1
0
        public IHttpActionResult FindComp(int id)
        {
            //Finding the data
            WoWComp Comp = db.Comps.Find(id);

            //if not found return 404
            if (Comp == null)
            {
                return(NotFound());
            }

            //put into dto
            WoWComp CompDto = new WoWComp
            {
                CompID     = Comp.CompID,
                CompName   = Comp.CompName,
                CompClass1 = Comp.CompClass1,
                CompClass2 = Comp.CompClass2,
                CompClass3 = Comp.CompClass3
            };

            Debug.WriteLine(Comp);
            //pass along data
            return(Ok(CompDto));
        }
Example #2
0
        public IHttpActionResult UpdateComp(int id, [FromBody] WoWComp Comp)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != Comp.CompID)
            {
                return(BadRequest());
            }

            db.Entry(Comp).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CompExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
        public IHttpActionResult AddComp([FromBody] WoWComp Comp)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Comps.Add(Comp);
            db.SaveChanges();

            return(Ok(Comp.CompID));
        }
Example #4
0
        public IHttpActionResult DeleteComp(int id)
        {
            WoWComp Comp = db.Comps.Find(id);

            if (Comp == null)
            {
                return(NotFound());
            }

            db.Comps.Remove(Comp);
            db.SaveChanges();

            return(Ok(Comp));
        }
        // GET: Comp/Delete/5
        public ActionResult DeleteConfirm(int id)
        {
            string url = "compdata/findcomp/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                //Put data into comp dto
                WoWComp SelectedComp = response.Content.ReadAsAsync <WoWComp>().Result;
                return(View(SelectedComp));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        // GET: Comp/Details/5
        public ActionResult Details(int id)
        {
            // ShowComp ViewModel = new ShowComp();
            string url = "compdata/findcomp/" + id;

            HttpResponseMessage response = client.GetAsync(url).Result;

            //Catch the status code
            if (response.IsSuccessStatusCode)
            {
                //add data into comp data transfer object
                WoWComp SelectedComp = response.Content.ReadAsAsync <WoWComp>().Result;
                Debug.WriteLine(SelectedComp.CompName);
                //  ViewModel.comp = SelectedComp;
                url = "teamdata/getclassesforcomp/" + id;
                return(View(SelectedComp));
            }
            return(RedirectToAction("List"));
        }
        public ActionResult Edit(int id, WoWComp CompInfo)
        {
            Debug.WriteLine(CompInfo.CompName);
            string url = "compdata/updatecomp/" + id;

            Debug.WriteLine(jss.Serialize(CompInfo));
            HttpContent content = new StringContent(jss.Serialize(CompInfo));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = client.PostAsync(url, content).Result;

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction("Details", new { id = id }));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        public ActionResult Create(WoWComp CompInfo)
        {
            Debug.WriteLine(CompInfo.CompName);
            string url = "Compdata/addComp";

            Debug.WriteLine(jss.Serialize(CompInfo));
            HttpContent content = new StringContent(jss.Serialize(CompInfo));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = client.PostAsync(url, content).Result;

            if (response.IsSuccessStatusCode)
            {
                int Compid = response.Content.ReadAsAsync <int>().Result;
                return(RedirectToAction("Details", new { id = Compid }));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }