public ActionResult RequestDelivery(string address, int postID, string author, string brand_pro) { User _user = GetCurrentUser(); if (_user != null) { if (_user.user_id != author) { Dealed new_deal = new Dealed(); new_deal.is_pending = true; //Dang cho xac nhan tu nguoi gui new_deal.is_delivering = false; //Dang duoc van chuyen new_deal.is_dealed = false; //Da nhan dc hang new_deal.post_id = postID; new_deal.user_id = _user.user_id; DateTime currtime = DateTime.Now; new_deal.deal_date = currtime; db.Dealeds.Add(new_deal); // useeID = Session[user].user_id // postID = post dang xem.post id Notification noti = new Notification(); noti.follow_action = false; noti.post_action = false; noti.request_delivery = true; noti.post_id = postID; noti.time = currtime; noti.user_id = _user.user_id; noti.value = "Address: " + address; noti.reciever = author; noti.is_read = false; db.Notifications.Add(noti); db.SaveChanges(); return(Redirect("/Post/PostDetail/" + postID)); } else { return(Redirect("/Post/PostDetail/" + postID)); } } else { return(RedirectToAction("LoginAccount", "Login")); } }
public ActionResult DeleteDeal(int postID, string userID, int notiID) { //user nhan request Dealed dealed = db.Dealeds.Where(d => d.post_id == postID && d.user_id == userID && d.is_pending == true).FirstOrDefault(); string id = dealed.Post.user_id; User user = GetCurrentUser(); if (user != null && user.user_id == id) { Notification notification = db.Notifications.Where(n => n.notification_id == notiID).FirstOrDefault(); notification.is_read = true; db.Dealeds.Remove(dealed); db.SaveChanges(); return(RedirectToAction("Index", "Notification", new { userID = id })); } else { return(RedirectToAction("LoginAccount", "Login")); } }
public ActionResult DealDone(int _id) { //user request thuc hien thao tac nay Dealed dealed = db.Dealeds.Where(d => d.deal_id == _id).FirstOrDefault(); User user = GetCurrentUser(); if (user != null && user.user_id == dealed.user_id) { dealed.is_delivering = false; dealed.is_dealed = true; dealed.deal_date = DateTime.Now; db.Entry(dealed).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ProfileUser", "User", new { id = dealed.user_id })); } else { ViewBag.Forbiden = "You don't have permission to access this!"; return(PartialView("Nodelivery")); } }
public ActionResult AcceptDeal(int postID, string userID, int notiID) { //user nhan request Dealed dealed = db.Dealeds.Where(d => d.post_id == postID && d.is_pending == true && d.user_id == userID).FirstOrDefault(); string id = dealed.Post.user_id; User user = GetCurrentUser(); if (user != null && user.user_id == id) { Notification notification = db.Notifications.Where(n => n.notification_id == notiID).FirstOrDefault(); notification.is_read = true; dealed.is_pending = false; dealed.is_delivering = true; dealed.deal_date = DateTime.Now; db.Entry(dealed).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Notification", new { userID = id })); } else { return(RedirectToAction("LoginAccount", "Login")); } }