コード例 #1
0
        /// <summary>
        /// Insert/Update New Data
        /// </summary>
        public ActionResult Post(ViewLeaveRequest data)
        {
            LeaveRequest lr = new LeaveRequest()
            {
                ID_LeaveRequest=data.ID_LeaveRequest,
                ID_Requestor=data.ID_Requestor,
                ID_Approver=data.ID_Approver,
                LeaveCategory=data.ID_LeaveCategory,
                LeaveReason=data.LeaveReason,
                StartDate=data.StartDate,
                EndDate=data.EndDate,
                CreatedBy=0,
                ModifiedBy=0,
                ModifiedDate=DateTime.Now,
                CreatedDate=DateTime.Now
            };

            if (data.ID_LeaveRequest==0)
            {
                //Add New Item
                new CGPSI_AbsenceDBEntities().LeaveRequests.Add(lr);
            }
            else
            {
                CGPSI_AbsenceDBEntities temp =new CGPSI_AbsenceDBEntities();
                temp.Entry(lr).CurrentValues.SetValues(lr);
                temp.SaveChanges();
            }
            return Json(true);
        }
コード例 #2
0
 /// <summary>
 /// Delete Data
 /// </summary>
 public ActionResult Delete(ViewLeaveRequest data)
 {
     LeaveRequest lr = new LeaveRequest()
     {
         ID_LeaveRequest = data.ID_LeaveRequest,
         ID_Requestor = data.ID_Requestor,
         ID_Approver = data.ID_Approver,
         LeaveCategory = data.ID_LeaveCategory,
         LeaveReason = data.LeaveReason,
         StartDate = data.StartDate,
         EndDate = data.EndDate,
         CreatedBy = 0,
         ModifiedBy = 0,
         ModifiedDate = DateTime.Now,
         CreatedDate = DateTime.Now
     };
     CGPSI_AbsenceDBEntities temp = new CGPSI_AbsenceDBEntities();
     temp.LeaveRequests.Remove(temp.LeaveRequests.Where(t=>t.ID_LeaveRequest==data.ID_LeaveRequest).FirstOrDefault());
     return Json(temp.SaveChanges());
 }