public HttpResponseMessage GetAllFromAgency([FromBody] ListNhanVienChiNhanh request)
        {
            var response = new PhanCongResponse();

            if (BusinessHandler.TokenBUS.tokenCheck(request, response, 2))
            {
                try
                {
                    BusinessHandler.PhanCongBUS.GetAllFromAgency(request, ref response);
                }
                catch (Exception)
                {
                    response.Errors.Add("Lỗi hệ thống");
                    response.IsError = true;
                }
            }
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Example #2
0
        public static void GetAllFromAgency(ListNhanVienChiNhanh request, ref PhanCongResponse response)
        {
            PhanCongRepository pc_repository = new PhanCongRepository();
            string             condition     = "";

            for (int i = 0; i < request.Data.Count; i++)
            {
                if (i == request.Data.Count - 1)
                {
                    condition = condition + "MaNV='" + request.Data[i].manhanvien + "'";
                }
                else
                {
                    condition = condition + "MaNV='" + request.Data[i].manhanvien + "' or ";
                }
            }
            if (!string.IsNullOrEmpty(condition))
            {
                condition = "(" + condition + ")";
            }
            var result = PhanCongRepository.GetAllFromAgency(condition);

            if (result != null)
            {
                foreach (var item in result)
                {
                    item.NgayBatDauFormatted  = item.NgayBatDau.ToString("dd-MM-yyyy");
                    item.NgayKetThucFormatted = item.NgayKetThuc.ToString("dd-MM-yyyy");
                    foreach (var rqitem in request.Data)
                    {
                        if (item.MaNV == rqitem.manhanvien)
                        {
                            item.HoTen = rqitem.hoten;
                        }
                    }
                }
                response.Data = result;
            }
            else
            {
                response.Errors.Add("Có lỗi xảy ra!");
                response.IsError = true;
            }
        }