示例#1
0
        // GET: Articles/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            criteria article = db.criterias.Find(id);

            if (article == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ModuleID = id.Value;

            var comments = db.criteriaCommentss.Where(d => d.ModuleId.Equals(id.Value)).ToList();

            ViewBag.Comments = comments;

            var ratings = db.criteriaCommentss.Where(d => d.ModuleId.Equals(id.Value)).ToList();

            if (ratings.Count() > 0)
            {
                var ratingSum = ratings.Sum(d => d.Rating.Value);
                ViewBag.RatingSum = ratingSum;
                var ratingCount = ratings.Count();
                ViewBag.RatingCount = ratingCount;
            }
            else
            {
                ViewBag.RatingSum   = 0;
                ViewBag.RatingCount = 0;
            }

            return(View(article));
        }
示例#2
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            criteria criteria = new criteria();

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:9080/pidev-web/");
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            //houni essta3mlt service GetProjectById
            HttpResponseMessage response = client.GetAsync("rest/criteria/" + id).Result;

            if (response.IsSuccessStatusCode)
            {
                criteria = response.Content.ReadAsAsync <criteria>().Result;
                UpdateModel(criteria, collection);

                // TODO: Add insert logic here

                HttpClient client2 = new HttpClient();
                client2.BaseAddress = new Uri("http://localhost:9080/pidev-web/");
                client2.PutAsJsonAsync <criteria>("rest/criteria", criteria).ContinueWith((postTask) => postTask.Result.IsSuccessStatusCode);
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View());
            }
        }
示例#3
0
        public ActionResult DeleteConfirmed(int id)
        {
            criteria article = db.criterias.Find(id);

            db.criterias.Remove(article);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#4
0
 public ActionResult Edit([Bind(Include = "AutoId,Topic,Description,Active")] criteria criteria)
 {
     if (ModelState.IsValid)
     {
         db.Entry(criteria).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(criteria));
 }
示例#5
0
        public ActionResult Create([Bind(Include = "AutoId,Topic,Description,Active, DateCreated")] criteria criteria)
        {
            if (ModelState.IsValid)
            {
                criteria.DateCreated = DateTime.Now;

                db.criterias.Add(criteria);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(criteria));
        }
示例#6
0
        // GET: Articles/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            criteria article = db.criterias.Find(id);

            if (article == null)
            {
                return(HttpNotFound());
            }
            return(View(article));
        }
示例#7
0
        public ActionResult Edit(int id)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:9080/pidev-web/");
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage response = client.GetAsync("rest/criteria/" + id).Result;
            criteria            project  = new criteria();

            if (response.IsSuccessStatusCode)
            {
                project = response.Content.ReadAsAsync <criteria>().Result;
            }
            else
            {
                ViewBag.project = "erreur";
            }

            return(View(project));
        }
示例#8
0
 ArtistSortRule.ReleaseDate => OrderByReleaseDate(criteria, SortDirection.Descending),