public async Task <IHttpActionResult> Putreview(int id, review review)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != review.movieid)
            {
                return(BadRequest());
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!reviewExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult createfeedback()
        {
            foreach (var transaction in db.transactions)
            {
                if (transaction.order.status == OrderStatus.SHIPPED.ToString())
                {
                    var fb = new review
                    {
                        created              = DateTime.UtcNow,
                        rating_overall       = 3,
                        rating_willshopagain = 3,
                        rating_delivery      = 3,
                        rating_support       = 3,
                        pending              = true,
                        subdomainid          = transaction.order.user1.organisation1.subdomain
                    };
                    repository.AddReview(fb);

                    // update transaction
                    transaction.reviewid = fb.id;
                }
            }
            db.SubmitChanges();

            return(Content("DONE"));
        }
Exemple #3
0
        public ActionResult Update(review rev)
        {
            var crud = new DataAccess();

            // crud.Update(rev);
            return(RedirectToAction("Index", "Review"));
        }
        public async Task <IActionResult> Putreview(long id, review review)
        {
            if (id != review.Id)
            {
                return(BadRequest());
            }

            _context.Entry(review).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!reviewExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #5
0
        public IActionResult request(string number, string male, string female, string fare)
        {
            if (HttpContext.Session.GetString("user") != null)
            {
                ViewData["av"] = "Available Male seat : " + male.ToString() + " Female Seat : " + female.ToString();
                HttpContext.Session.SetString("requestInfo", number.ToString() + "," + male.ToString() + "," + female.ToString() + "," + fare.ToString());
                string        connectionString = configuration.GetConnectionString("DefaultConnectionString");
                SqlConnection connection       = new SqlConnection(connectionString);
                connection.Open();
                string     query = "Select * from review where dri_id in(select dri_id from bus where number_plate = '" + number.ToString() + "')";
                SqlCommand com   = new SqlCommand(query, connection);
                com.CommandType = System.Data.CommandType.Text;
                SqlDataReader reader = com.ExecuteReader();
                var           model  = new List <review>();
                while (reader.Read())
                {
                    review rv = new review();
                    rv.cusid = reader["cusId"].ToString();
                    rv.driId = reader["dri_id"].ToString();
                    rv.rev   = reader["rev"].ToString();
                    model.Add(rv);
                }


                return(View(model));
            }
            else
            {
                return(RedirectToAction("notAccess", "Admin"));
            }
        }
        public async Task <ActionResult <review> > Postreview(review review)
        {
            _context.review.Add(review);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Getreview", new { id = review.Id }, review));
        }
        public IHttpActionResult Postreview(review review)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.reviews.Add(review);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (reviewExists(review.UserId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = review.UserId }, review));
        }
        public IHttpActionResult Putreview(string id, review review)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != review.UserId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #9
0
        public static void insertReview(int productId, String name, String review, int stars)
        {
            using (DB_entities db = new DB_entities())
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    review rev = new review();
                    rev.name       = name;
                    rev.product_id = productId;
                    rev.stars      = stars;
                    rev.comment    = review;

                    try
                    {
                        db.reviews.Add(rev);
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        Log.error("insertReview - Insert.cs", DateTime.Now, ex);
                    }
                    scope.Complete();
                }
            }
        }
        // DELETE: api/Reviews/5
        public string DeleteReview(string id)
        {
            review selRev = null;

            using (var ctx = new Assignment2Entities())
            {
                //finds review
                selRev = ctx.reviews
                         .Where(s => (s.reviewId).ToString() == id)
                         .FirstOrDefault();

                //return error if review not found
                if (selRev == null)
                {
                    return("Not a valid song");
                }
                else
                {
                    //deletes review
                    ctx.reviews.Remove(selRev);
                    ctx.SaveChanges();
                    return("Success");
                }
            }
        }
Exemple #11
0
        public ActionResult DeleteConfirmed(int id)
        {
            review review = db.reviews.Find(id);

            db.reviews.Remove(review);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #12
0
    /// <summary>
    /// Add review to the table
    /// </summary>
    /// <param name="toAdd"></param>
    protected void addReview(review toAdd)
    {
        TableRow  fRow  = new TableRow();
        TableRow  tRow  = new TableRow();
        TableCell cell1 = new TableCell();

        cell1.BorderStyle = border;
        cell1.BorderWidth = width;
        TableCell cell2 = new TableCell();
        TableCell cell3 = new TableCell();

        cell3.BorderStyle = border;
        cell3.BorderWidth = width;
        if (Session["User"] is customer)
        {
            cell1.Text = toAdd.rCustomer.getFullName;                              //Customer name
        }
        else
        {
            LinkButton newBTN = new LinkButton();
            newBTN.Text   = toAdd.rCustomer.getFullName;
            newBTN.Click += (e, a) =>
            {
                Session["Customer"] = toAdd.rCustomer;
                Response.Redirect("~//custPGE.aspx");
            };
            cell1.Controls.Add(newBTN);
        }
        double r = toAdd.getRating;
        Color  t;

        if (r < 3)
        {
            t = Color.PaleVioletRed;
        }
        else
        {
            t = Color.LightGreen;
        }
        //cell2.ForeColor = Color.White;
        cell2.BackColor       = t;
        cell2.BorderStyle     = border;
        cell2.BorderWidth     = width;
        cell2.HorizontalAlign = HorizontalAlign.Center;
        cell2.Font.Bold       = true;
        cell2.Text            = string.Format("{0:0.0}", r.ToString());
        fRow.Cells.Add(cell1);
        fRow.Cells.Add(cell2);
        reviewTBL.Rows.Add(fRow);
        cell3.Text       = toAdd.getComments;
        cell3.ColumnSpan = 2; //Span 2 columns
        tRow.Cells.Add(cell3);
        reviewTBL.Rows.Add(tRow);
        TableRow paddRow = new TableRow();

        paddRow.Cells.Add(new TableCell());
        reviewTBL.Rows.Add(paddRow);
    }
        public IActionResult submit(review Review)
        {
            _context.users.Add(Review);
            _context.SaveChanges();



            return(RedirectToAction("reviews"));
        }
Exemple #14
0
 public ActionResult Edit([Bind(Include = "developerId,Name,Subject,Description,number_of_Stars")] review review)
 {
     if (ModelState.IsValid)
     {
         db.Entry(review).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(review));
 }
Exemple #15
0
        public ActionResult Create(review rev)
        {
            //string _name, int _score, string _message, int _rest_id
            var crud = new DataAccess();

            crud.AddReview(rev.name, rev.score, rev.message, rev.rest_id);
            // do this see if it crashes
            //var temp = crud.GetReviews(3);
            return(RedirectToAction("Index", "Review"));
        }
Exemple #16
0
        public ActionResult Create([Bind(Include = "developerId,Name,Subject,Description,number_of_Stars")] review review)
        {
            if (ModelState.IsValid)
            {
                db.reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(review));
        }
        public async Task <IHttpActionResult> Getreview(int id)
        {
            review review = await db.reviews.FindAsync(id);

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

            return(Ok(review));
        }
Exemple #18
0
        public static review ToDataLayer(Review reviewLib, restaurant restaurantData)
        {
            review reviewData = new review();

            reviewData.id           = reviewLib.id;
            reviewData.reviewerName = reviewLib.name;
            reviewData.comment      = reviewLib.comment;
            reviewData.rating       = (float)reviewLib.rating;
            reviewData.date         = reviewLib.dateTime;
            reviewData.restaurant   = restaurantData;

            return(reviewData);
        }
Exemple #19
0
        // GET: reviews/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            review review = db.reviews.Find(id);

            if (review == null)
            {
                return(HttpNotFound());
            }
            return(View(review));
        }
        public IHttpActionResult Deletereview(string id)
        {
            review review = db.reviews.Find(id);

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

            db.reviews.Remove(review);
            db.SaveChanges();

            return(Ok(review));
        }
 // POST: api/Reviews
 public string PostReview(review revPost)
 {
     using (var ctx = new Assignment2Entities())
     {
         if (!ModelState.IsValid)
         {
             return("Post Failed");
         }
         //inserts review
         ctx.reviews.Add(revPost);
         ctx.SaveChanges();
         return("Success");
     }
 }
        public async Task <IHttpActionResult> Deletereview(int id)
        {
            review review = await db.reviews.FindAsync(id);

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

            db.reviews.Remove(review);
            await db.SaveChangesAsync();

            return(Ok(review));
        }
        // PUT: api/Reviews/5
        public string PutReview(review revPut)
        {
            using (var ctx = new Assignment2Entities())
            {
                if (!ModelState.IsValid)
                {
                    return("Put Failed");
                }
                //edits review
                ctx.Entry(revPut).State = EntityState.Modified;

                ctx.SaveChanges();
                return("Success");
            }
        }
Exemple #24
0
 public ActionResult Add_review(FormCollection collection)
 {
     if (ModelState.IsValid)
     {
         review revie = new review();
         if (Session["UserAccount"] == null)
         {
             return(new HttpNotFoundResult()); // 404
         }
         else
         {
             userr users   = (userr)Session["UserAccount"];
             int   film_id = int.Parse(collection["film"]);
             revie.created = DateTime.Now;
             revie.user_id = users.id;
             revie.film_id = film_id;
             revie.comment = collection["comment"];
             revie.title   = collection["title"];
             revie.point   = int.Parse(collection["point"]);
             data.reviews.InsertOnSubmit(revie);
             data.SubmitChanges();
             // cap nhat diem cua phim
             var review = data.reviews.Where(or => or.film_id == film_id).ToList();
             if (review.Count() > 0)
             {
                 int sum = 0;
                 foreach (var item in review)
                 {
                     sum += int.Parse((item.point).ToString());
                 }
                 float point = sum / (review.Count());
                 film  fil   = data.films.Where(or => or.id == film_id).FirstOrDefault();
                 fil.rate = int.Parse((Math.Ceiling(point)).ToString());
                 UpdateModel(fil);
                 data.SubmitChanges();
             }
             else
             {
                 ;
             }
             return(RedirectToAction("Film_single", "Home", new { id = film_id }));
         }
     }
     else
     {
         return(HttpNotFound());
     }
 }
Exemple #25
0
        public ActionResult Review([Bind(Include = "Id,rating,comment,user_id,paper_id")] review review)
        {
            string current = User.Identity.GetUserId();

            review.user_id  = current;
            review.paper_id = reserved;
            if (ModelState.IsValid)
            {
                db.review.Add(review);
                db.SaveChanges();
                if (User.IsInRole("Admin"))
                {
                    return(RedirectToAction("IndexAdmin"));
                }
                return(RedirectToAction("IndexRev"));
            }
            return(View(review));
        }
Exemple #26
0
        //Executes a command parsed at the db and returns relevant reviews
        public List <review> getReviewsFromDB(string commandText)
        {
            List <review>   qryReviews = new List <review>();
            var             connString = settings.ItemReviews;
            MySqlConnection conn       = new MySqlConnection(connString);
            MySqlCommand    command    = conn.CreateCommand();

            try
            {
                conn.Open();
                command.CommandText = commandText;


                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    review r = new review();
                    try
                    {
                        r.ItemName                      = reader.GetString(0);
                        r.ReviewersOfReview             = reader.GetInt16(1);
                        r.ReviewersOfReviewFoundHelpful = reader.GetInt16(2);
                        r.StarsGiven                    = reader.GetInt16(3);
                        r.ShortReview                   = reader.GetString(4);
                        r.ReviewerId                    = reader.GetString(5);
                        r.ReviewLocation                = reader.GetString(6);
                        r.IsAmazonVerifiedPurchase      = reader.GetBoolean(7);
                        r.LongReview                    = reader.GetString(8);
                        qryReviews.Add(r);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
            }
            catch (MySqlException ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(qryReviews);
        }
Exemple #27
0
        public ActionResult Create(int id, Decimal gameId, FormCollection form)
        {
            bool    check = form["id"] != null;
            Decimal gId   = Decimal.Parse(form["gameId"]);

            review review = db.reviews.Find(id);

            if (review == null)
            {
                return(HttpNotFound());
            }
            review.approve = check;
            db.SaveChanges();

            var reviewList = db.reviews
                             .Where(c => c.gameId == gId);

            return(View("Index", reviewList.ToList()));
        }
Exemple #28
0
        public ActionResult Review(int id)
        {
            reserved = id;
            review review  = new review();
            string current = User.Identity.GetUserId();
            // Make sure a paper can't be reviewed twice by the same person
            // Check if <= deadline
            var      deadpaper = db.paper.FirstOrDefault(p => p.Id == id);
            var      deadconf  = db.Conf.FirstOrDefault(c => c.Id == deadpaper.conf_id);
            DateTime?deadline  = deadconf.rev_deadline;

            if (db.review.Any(r => r.paper_id == reserved && r.user_id == current) || deadline <= DateTime.Now)
            {
                if (User.IsInRole("Admin"))
                {
                    return(RedirectToAction("IndexAdmin"));
                }
                return(RedirectToAction("IndexRev"));
            }
            return(View(review));
        }
Exemple #29
0
 public static int addReview(String name, String text, int productId, int stars)
 {
     using (DB_entities db = new DB_entities())
     {
         review prodReview = new review();
         prodReview.name       = name;
         prodReview.comment    = text;
         prodReview.product_id = productId;
         prodReview.stars      = stars;
         try
         {
             db.reviews.Add(prodReview);
             db.SaveChanges();
             return(prodReview.id);
         }
         catch (Exception ex)
         {
             Log.error("addReview - Insert.cs", DateTime.Now, ex);
             return(0);
         }
     }
 }
Exemple #30
0
        public ActionResult Index(Decimal id, String txtAreaReview, FormCollection form)
        {
            if (id != null && txtAreaReview != null)
            {
                String rate     = form["rate"];
                review review   = new review();
                var    username = Session["User"].ToString();
                review.gameId   = id;
                review.review1  = txtAreaReview;
                review.username = username;
                review.rating   = Int32.Parse(rate);
                review p     = db.reviews.OrderByDescending(c => c.id).FirstOrDefault();
                int    newId = (null == p ? 0 : p.id) + 1;
                review.id = newId;
                db.reviews.Add(review);
                db.SaveChanges();
            }

            var reviewList = db.reviews
                             .Where(c => c.gameId == id);

            return(View(reviewList.ToList()));
        }