//
        // GET: /Sys_LockObject/
        //// GET api/<controller>
        ///// <summary>
        ///// Lấy tất cả dữ liệu
        ///// </summary>
        ///// <returns></returns>
        public IEnumerable<Sys_LockObjectModel> Get()
        {
            string status = string.Empty;
            var service = new Sys_LockObjectServices();
            var list = service.GetAllUseEntity<Sys_LockObjectEntity>(ref status);

            return list.Translate<Sys_LockObjectModel>();

        }
        public void Approved(Guid selectedIds, string status, Guid? workPlaceID, string OrderNumber, string userLoginName)
        {

            using (var context = new VnrHrmDataContext())
            {
                string statusMessage = string.Empty;

                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoAtt_CutOffDuration = new CustomBaseRepository<Att_CutOffDuration>(unitOfWork);
                int[] orderNumber = null;
                if (!string.IsNullOrEmpty(OrderNumber))
                {
                    orderNumber = OrderNumber.Split(',').Select(s => int.Parse(s)).ToArray();
                }
                string strOrg = string.Empty;
                if (orderNumber != null)
                {
                    strOrg = string.Join(",", orderNumber.OrderBy(s => s).ToList());
                }

                var lockObjectServices = new Sys_LockObjectServices();
                var objLockObj = new List<object>();
                objLockObj.AddRange(new object[5]);

                objLockObj[3] = 1;
                objLockObj[4] = int.MaxValue - 1;
                var lstLockObject = lockObjectServices.GetData<Sys_LockObjectEntity>(objLockObj, ConstantSql.hrm_sys_sp_get_LockObject, userLoginName, ref statusMessage).Where(s => s.Type == "E_APPROVED_PAYROLL").ToList();

                List<object> listModel = new List<object>();
                listModel.AddRange(new object[3]);
                listModel[1] = 1;
                listModel[2] = Int32.MaxValue - 1;
                List<Att_CutOffDurationEntity> listCutoffduration_All = GetData<Att_CutOffDurationEntity>(listModel, ConstantSql.hrm_att_sp_get_CutOffDurations, userLoginName, ref status).Where(s => s.ID == selectedIds).ToList();

                var cutOffEntity = new Att_CutOffDurationEntity();
                if (selectedIds != Guid.Empty)
                {
                    cutOffEntity = listCutoffduration_All.Where(s => selectedIds == s.ID).FirstOrDefault();
                }
                var lockObjectEntity = new Sys_LockObjectEntity();
                if (cutOffEntity != null)
                {
                    lockObjectEntity = lstLockObject.Where(s => s.DateStart == cutOffEntity.DateStart && s.DateEnd == cutOffEntity.DateEnd).FirstOrDefault();
                }

                if (lockObjectEntity != null)
                {
                    if (orderNumber != null)
                    {
                        lockObjectEntity.OrgStructures = Common.ListNumbersToBinary(orderNumber.ToList());
                        lockObjectEntity.WorkPlaceID = workPlaceID;
                        lockObjectServices.Edit(lockObjectEntity);
                    }
                }
                else
                {
                    if (orderNumber != null)
                    {
                        var lockObjectNewEntity = new Sys_LockObjectEntity();
                        lockObjectNewEntity.DateStart = cutOffEntity.DateStart;
                        lockObjectNewEntity.DateEnd = cutOffEntity.DateEnd;
                        lockObjectNewEntity.OrgStructures = Common.ListNumbersToBinary(orderNumber.ToList());
                        lockObjectNewEntity.Status = EnumDropDown.LockObjectStatus.E_WAITING_APPROVED.ToString();
                        lockObjectNewEntity.WorkPlaceID = workPlaceID;
                        lockObjectNewEntity.UserCreate = userLoginName;
                        lockObjectNewEntity.Type = "E_APPROVED_PAYROLL";
                        lockObjectServices.Add(lockObjectNewEntity);
                    }
                }

            }
        }
        public Sys_LockObjectModel Put(Sys_LockObjectModel model)
        {
            var Sys_LockObject = model.CopyData<Sys_LockObjectEntity>();

            var service = new Sys_LockObjectServices();
            if (model.ID != Guid.Empty)
            {
                Sys_LockObject.ID = model.ID;
                service.Edit<Sys_LockObjectEntity>(Sys_LockObject);
            }
            else
            {
                service.Add<Sys_LockObjectEntity>(Sys_LockObject);
            }
            return model;
        }