public bool Delete(ThongTinLuongEntity thongTinLuongEntity)
 {
     try
     {
         this.m_UnitOfWork.ThongTinLuongRepository.Delete(thongTinLuongEntity);
         return true;
     }
     catch (Exception e)
     {
         System.Console.WriteLine(e.ToString());
         return false;
     }
 }
        public bool Create(ThongTinLuongEntity thongTinLuongEntity)
        {
            using (var scope = new TransactionScope())
            {
                var thongTinLuong = new ThongTinLuongs
                {
                    Id = thongTinLuongEntity.Id,
                    Thang = thongTinLuongEntity.Thang,
                    Nam = thongTinLuongEntity.Nam,
                    HeSoLuong = thongTinLuongEntity.HeSoLuong,
                    Ngach_Bac = thongTinLuongEntity.Nganh_Bac,
                    ThongTinLuong_ThongTin2C = thongTinLuongEntity.ThongTinLuong_ThongTin2C
                };

                m_UnitOfWork.ThongTinLuongRepository.Insert(thongTinLuong);
                m_UnitOfWork.Save();
                scope.Complete();
                return true;
            }
        }
        /// only return json to client
        public ActionResult Create(ThongTinLuongEntity thongTinLuongEntity)
        {
            ThongTinLuongServices service = new ThongTinLuongServices();

            if (thongTinLuongEntity == null)
            {
                RenderResult.RequestError(ViewData, "Lỗi đối số không hợp lệ");
                return Json(JsonConvert.SerializeObject(ViewData));
            }

            if (service.Create(thongTinLuongEntity))
            {
                return Json(RenderResult.RequestCompleted(ViewData, "Thêm thông tin lương thành công"));
            }
            else
            {

                return Json(RenderResult.RequestCompleted(ViewData, "Lỗi khi thêm thông tin lương"));
            }
        }
        public ActionResult Edit(ThongTinLuongEntity thongTinLuongEntity)
        {
            ThongTinLuongServices service = new ThongTinLuongServices();

            if (thongTinLuongEntity == null)
            {
                return Json(RenderResult.RequestError(ViewData, "Lỗi đối số không hợp lệ"), JsonRequestBehavior.AllowGet);
            }

            try
            {
                if (service.Update(thongTinLuongEntity))
                    return Json(RenderResult.RequestCompleted(ViewData, "Chỉnh sửa thành công"));

                return Json(RenderResult.RequestCompleted(ViewData, "Chỉnh sửa không thành công"));
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());

                return Json(RenderResult.RequestError(ViewData, "Lỗi xảy ra"));
            }
        }
        public bool Update(ThongTinLuongEntity thongTinLuongEntity)
        {
            var success = false;
            if (thongTinLuongEntity != null)
            {
                using (var scope = new TransactionScope())
                {
                    var ttLuong = m_UnitOfWork.ThongTinLuongRepository.GetByID(thongTinLuongEntity.Id);
                    if (ttLuong != null)
                    {
                        ttLuong.Id = thongTinLuongEntity.Id;
                        ttLuong.Nam = thongTinLuongEntity.Nam;
                        ttLuong.Thang = thongTinLuongEntity.Thang;
                        ttLuong.HeSoLuong = thongTinLuongEntity.HeSoLuong;
                        ttLuong.Ngach_Bac = thongTinLuongEntity.Nganh_Bac;
                        ttLuong.ThongTinLuong_ThongTin2C = thongTinLuongEntity.ThongTinLuong_ThongTin2C;

                        m_UnitOfWork.ThongTinLuongRepository.Update(ttLuong);
                        m_UnitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return success;
        }
        public List<ThongTinLuongEntity> GetAll()
        {
            IEnumerable<ThongTinLuongs> model = this.m_UnitOfWork.ThongTinLuongRepository.GetAll();
            List<ThongTinLuongEntity> result = new List<ThongTinLuongEntity>();

            foreach (var item in model)
            {
                ThongTinLuongEntity ttLuong = new ThongTinLuongEntity
                {
                    Id = item.Id,
                    Thang = item.Thang,
                    Nam = item.Nam,
                    HeSoLuong = item.HeSoLuong,
                    Nganh_Bac = item.Ngach_Bac,
                    ThongTinLuong_ThongTin2C = item.ThongTinLuong_ThongTin2C
                };
                result.Add(ttLuong);
            }

            return result;
        }
        public ActionResult Delete(ThongTinLuongEntity thongTinLuongEntity)
        {
            ThongTinLuongServices service = new ThongTinLuongServices();

            try
            {
                if (service.Delete(thongTinLuongEntity))
                    return Json(RenderResult.RequestCompleted(ViewData, "Xóa thành công"));

                return Json(RenderResult.RequestCompleted(ViewData, "Xóa không thành công"));
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
                return Json(RenderResult.RequestError(ViewData, "Lỗi xảy ra"));
            }

        }