public ActionResult AddRequest(LeaveRequest leaveRequest)
        {
            int id = Int32.Parse(Session["LogedUserId"].ToString());
            leaveRequest.Employee_Id = id;
            leaveRequest.DateOfApplication = DateTime.Today;
            leaveRequest.Status = "Requested";
            /*string startingDate = collection.Get("sDate").ToString();
            string endingDate = collection.Get("eDate").ToString();
            string leaveType = collection.Get("leaveType").ToString();
            System.Diagnostics.Debug.Write("Leave type : " + leaveType);
            System.Diagnostics.Debug.Write("EDate : " + endingDate);
            string reason = collection.Get("reason").ToString();
            LeaveRequest leaveRequest = new LeaveRequest();
            leaveRequest.FromDate = Convert.ToDateTime(startingDate);

            leaveRequest.ToDate = Convert.ToDateTime(startingDate);
            leaveRequest.DateOfApplication = DateTime.Today;
            leaveRequest.TypeOfLeave = leaveType;
            leaveRequest.Reason = reason;
            leaveRequest.Employee_Id = id;*/

            db.LeaveRequests.AddObject(leaveRequest);
            db.SaveChanges();
            return RedirectToAction("Index", "Attendance");
        }
        public ActionResult Create(LeaveRequest leaverequest)
        {
            if (ModelState.IsValid)
            {
                db.LeaveRequests.AddObject(leaverequest);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.Employee_Id = new SelectList(db.Employees, "EmployeeId", "Name", leaverequest.Employee_Id);
            return View(leaverequest);
        }
 public ActionResult Edit(LeaveRequest leaverequest)
 {
     if (ModelState.IsValid)
     {
         db.LeaveRequests.Attach(leaverequest);
         db.ObjectStateManager.ChangeObjectState(leaverequest, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.Employee_Id = new SelectList(db.Employees, "EmployeeId", "Name", leaverequest.Employee_Id);
     return View(leaverequest);
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the LeaveRequests EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToLeaveRequests(LeaveRequest leaveRequest)
 {
     base.AddObject("LeaveRequests", leaveRequest);
 }
 /// <summary>
 /// Create a new LeaveRequest object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="dateOfApplication">Initial value of the DateOfApplication property.</param>
 /// <param name="fromDate">Initial value of the FromDate property.</param>
 /// <param name="toDate">Initial value of the ToDate property.</param>
 /// <param name="typeOfLeave">Initial value of the TypeOfLeave property.</param>
 /// <param name="reason">Initial value of the Reason property.</param>
 /// <param name="employee_Id">Initial value of the Employee_Id property.</param>
 public static LeaveRequest CreateLeaveRequest(global::System.Int32 id, global::System.DateTime dateOfApplication, global::System.DateTime fromDate, global::System.DateTime toDate, global::System.String typeOfLeave, global::System.String reason, global::System.Int32 employee_Id)
 {
     LeaveRequest leaveRequest = new LeaveRequest();
     leaveRequest.Id = id;
     leaveRequest.DateOfApplication = dateOfApplication;
     leaveRequest.FromDate = fromDate;
     leaveRequest.ToDate = toDate;
     leaveRequest.TypeOfLeave = typeOfLeave;
     leaveRequest.Reason = reason;
     leaveRequest.Employee_Id = employee_Id;
     return leaveRequest;
 }