public async Task <ActionResult> GetPersonalInfo([FromBody] PersonalInfoQuery personalInfo) { var result = await _mediator.Send(personalInfo); if (result == null) { return(Ok(new HttpResponse { Code = 201, Message = "User not exist" })); } return(Ok(new PersonalInfoResponseDto { Code = 200, Personal = result })); }
public IActionResult GetAllBranchsByBankId(string Digits, int SearchType) { try { if (SearchType == 1) { if (string.IsNullOrEmpty(Digits)) { return(StatusCode(406, "الرجاء ادخال الرقم الوطني")); } if (Digits.Length < 12) { return(StatusCode(406, "الرجاء ادخال الرقم الوطني بطريقة الصحيحه")); } } else { if (string.IsNullOrEmpty(Digits)) { return(StatusCode(406, "الرجاء ادخال رقم الهاتف")); } if (Digits.Length < 9) { return(StatusCode(406, "الرجاء ادخال رقم الهاتف بطريقة الصحيحه")); } } IQueryable <PersonalInfo> PersonalInfoQuery; string CorrectPhone = Digits.Substring(Digits.Length - 9); if (SearchType == 1) { PersonalInfoQuery = from p in db.PersonalInfo where p.Status == 3 && p.Nid == Digits select p; } else { PersonalInfoQuery = from p in db.PersonalInfo where p.Status == 3 && p.Phone == CorrectPhone select p; } if (PersonalInfoQuery.Count() != 1) { return(StatusCode(404, "لاتوجد بيانات اشتراك لهذا المواطن , الرجاء انشاء حافظه اولا")); } var PersonalInfoList = (from p in PersonalInfoQuery select new { p.Name, p.FatherName, p.SurName, p.GrandName, p.PassportNumber, p.CreatedOn, p.Phone, p.Nid, p.Id, p.DepositType }).Single(); var UserType = this.help.GetCurrentUserType(HttpContext); // admin see every thing dynamic CashIn = null; if (UserType == 1) { CashIn = db.BanksysBankActions.Where(x => x.CashIn.Personal.Id == PersonalInfoList.Id && x.CashIn.DepositType == 3 && x.CashIn.Refrence == 3 && x.ActionType == 3).Select(t => new { t.CashIn.Valuedigits, t.CashIn.NumInvoiceDep, t.CashInId, t.CashIn.Description, t.Branch, t.Branch.Bank, t.CashIn.Status, t.ActionDate, FName = t.CashIn.Personal.Name, t.CashIn.Personal.FatherName, t.CashIn.Personal.SurName, t.CashIn.Personal.GrandName, t.CashIn.Personal.Nid, t.CashIn.Personal.Phone }).OrderByDescending(x => x.ActionDate).ToList(); } else if (UserType == 2) { var BranchId = this.help.GetCurrentBranche(HttpContext); var BankId = db.BanksysBranch.Where(u => u.BranchId == BranchId).Single().BankId; CashIn = db.BanksysBankActions.Where(x => x.CashIn.Personal.Id == PersonalInfoList.Id && x.CashIn.DepositType == 3 && x.CashIn.Refrence == 3 && x.Branch.BankId == BankId && x.ActionType == 3).Select(t => new { t.CashIn.Valuedigits, t.CashIn.NumInvoiceDep, t.CashInId, t.CashIn.Description, t.Branch, t.Branch.Bank, t.CashIn.Status, t.ActionDate, FName = t.CashIn.Personal.Name, t.CashIn.Personal.FatherName, t.CashIn.Personal.SurName, t.CashIn.Personal.GrandName, t.CashIn.Personal.Nid, t.CashIn.Personal.Phone }).OrderByDescending(x => x.ActionDate).ToList(); } else { var BranchId = this.help.GetCurrentBranche(HttpContext); var BankId = db.BanksysBranch.Where(u => u.BranchId == BranchId).Single().BankId; CashIn = db.BanksysBankActions.Where(x => x.CashIn.Personal.Id == PersonalInfoList.Id && x.CashIn.DepositType == 3 && x.CashIn.Refrence == 3 && x.BranchId == BranchId && x.ActionType == 3).Select(t => new { t.CashIn.Valuedigits, t.CashIn.NumInvoiceDep, t.CashInId, t.CashIn.Description, t.Branch, t.Branch.Bank, t.CashIn.Status, t.ActionDate, FName = t.CashIn.Personal.Name, t.CashIn.Personal.FatherName, t.CashIn.Personal.SurName, t.CashIn.Personal.GrandName, t.CashIn.Personal.Nid, t.CashIn.Personal.Phone }).OrderByDescending(x => x.ActionDate).ToList(); } return(Ok(new { PersonalInfo = PersonalInfoList, CashIn = CashIn })); } catch (Exception ex) { return(BadRequest(ex.Message)); } }