//Finding all by a buyer
 public IQueryable<Order> FindAllOrders(Buyer b)
 {
     return from Order in entities.Orders
            where Order.BuyerID == b.ID
            orderby Order.Date
            select Order;
 }
        public ActionResult Index(Buyer b)
        {
            if (ModelState.IsValid)
            {
                b.Valid = 1;
                buyerRepository.Add(b);

                /************** Saving log ***************/

                log.DoAll("Buyer: " + b.ID + ", " + b.Name + ", " + b.Pass
                    + ", " + b.ComName + ", " + b.Email + ", " + b.Country
                    + ", " + b.Valid + ".");

                /*****************************************/

                buyerRepository.Save();

                Session["buyerID"] = b.ID;
                return View("Confermation");
            }
            return View("~/Views/Home/Error.aspx");
        }
 public ActionResult Buyer(Buyer b)
 {
     return View();
 }
 //public bool Delete(int i) //return true if success, false otherwise
 //{
 //    try
 //    {
 //        Buyer tmp = entities.Buyers.First(d => d.ID == i);
 //        tmp.Valid = 0;
 //        return true;
 //    }
 //    catch (Exception e)
 //    {
 //        return false;
 //    }
 //}
 public void Delete(Buyer b)
 {
     /*Buyer tmp = entities.Buyers.First(d => d.ID == b.ID);*/
     b.Valid = 0;
 }
 //Insert, Delete
 public void Add(Buyer b)
 {
     entities.Buyers.AddObject(b);
 }
 //
 // GET: /Registration/
 public ActionResult Index()
 {
     Buyer b = new Buyer();
     return View(b);
 }
 public ActionResult Details(Buyer b)
 {
     return View("Details", b);
 }
 /// <summary>
 /// Create a new Buyer object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="pass">Initial value of the Pass property.</param>
 /// <param name="comName">Initial value of the ComName property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="country">Initial value of the Country property.</param>
 /// <param name="valid">Initial value of the Valid property.</param>
 public static Buyer CreateBuyer(global::System.Int32 id, global::System.String name, global::System.String pass, global::System.String comName, global::System.String email, global::System.String country, global::System.Int32 valid)
 {
     Buyer buyer = new Buyer();
     buyer.ID = id;
     buyer.Name = name;
     buyer.Pass = pass;
     buyer.ComName = comName;
     buyer.Email = email;
     buyer.Country = country;
     buyer.Valid = valid;
     return buyer;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Buyers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBuyers(Buyer buyer)
 {
     base.AddObject("Buyers", buyer);
 }