public ActionResult Delete(BuyTheCar Car) { try { // TODO: Add delete logic here var mycar = db.BuyTheCars.Find(Car.Id); db.BuyTheCars.Remove(mycar); db.SaveChanges(); return(RedirectToAction("GetCarsByUser")); } catch { return(View(Car)); } }
public ActionResult Apply(string Message) { var UserId = User.Identity.GetUserId(); var CarId = (int)Session ["CarId"]; var check = db.BuyTheCars.Where(a => a.CarId == CarId && a.UserId == UserId).ToList(); if (check.Count < 1) { var Car = new BuyTheCar(); Car.CarId = CarId; Car.UserId = UserId; Car.Message = Message; Car.BuyingDate = DateTime.Now; db.BuyTheCars.Add(Car); db.SaveChanges(); ViewBag.Result = "تمت اضافة طلبك"; } else { ViewBag.Result = "حدث خطأ إما أنك قد تقدمت بالطلب مسبقا"; } return(View()); }