public ActionResult FilterPacient(BoardPacient data)
        {
            Api API = new Api();
            Dictionary <string, string> arg = new Dictionary <string, string>()
            {
                { "Pacient", data.Pacient },
                { "DocTypeId", data.DocTypeId.ToString() },
                { "DocNumber", data.DocNumber },
                { "Index", data.Index.ToString() },
                { "Take", data.Take.ToString() }
            };

            ViewBag.Pacients = API.Post <BoardPacient>("Pacient/GetBordPacients", arg);
            return(PartialView("_BoardPacientsPartial"));
        }
        public BoardPacient GetAllPacients(BoardPacient data)
        {
            try
            {
                var isDeleted      = (int)Enumeratores.SiNo.No;
                int groupDocTypeId = (int)Enumeratores.DataHierarchy.TypeDoc;
                int skip           = (data.Index - 1) * data.Take;

                //filters
                string filterPacient   = string.IsNullOrWhiteSpace(data.Pacient) ? "" : data.Pacient;
                string filterDocNumber = string.IsNullOrWhiteSpace(data.DocNumber) ? "" : data.DocNumber;

                var list = (from a in ctx.Pacient
                            join b in ctx.Person on a.v_PersonId equals b.v_PersonId
                            join c in ctx.DataHierarchy on new { a = b.i_DocTypeId.Value, b = groupDocTypeId } equals new { a = c.i_ItemId, b = c.i_GroupId }
                            where a.i_IsDeleted == isDeleted &&
                            (b.v_FirstName.Contains(filterPacient) || b.v_FirstLastName.Contains(filterPacient) || b.v_SecondLastName.Contains(filterPacient)) &&
                            (b.v_DocNumber.Contains(filterDocNumber)) &&
                            (data.DocTypeId == -1 || b.i_DocTypeId == data.DocTypeId)
                            select new Pacients
                {
                    PacientId = a.v_PersonId,
                    PacientFullName = b.v_FirstName + " " + b.v_FirstLastName + " " + b.v_SecondLastName,
                    DocType = c.v_Value1,
                    DocNumber = b.v_DocNumber,
                    TelephoneNumber = b.v_TelephoneNumber
                }).ToList();

                int totalRecords = list.Count;

                if (data.Take > 0)
                {
                    list = list.Skip(skip).Take(data.Take).ToList();
                }

                data.TotalRecords = totalRecords;
                data.List         = list;

                return(data);
            }
            catch (Exception ex)
            {
                throw;
            }
        }