예제 #1
0
        public async Task <IActionResult> Upsert(int?id)
        {
            IEnumerable <Institute> insList = await _insRepo.GetAllAsync(SD.InstituteAPIPath, HttpContext.Session.GetString("JWToken"));

            EmployeesVM objVM = new EmployeesVM()
            {
                InstituteList = insList.Select(i => new SelectListItem
                {
                    Text  = i.Name,
                    Value = i.Id.ToString()
                }),
                Employee = new Employee()
            };

            if (id == null)
            {
                //this will be true for Insert/Create
                return(View(objVM));
            }

            //Flow will come here for update
            objVM.Employee = await _employeeRepo.GetAsync(SD.EmployeeAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken"));

            if (objVM.Employee == null)
            {
                return(NotFound());
            }
            return(View(objVM));
        }
        public async Task <IActionResult> Index()
        {
            IndexVM listOfInstitutesAndEmployees = new IndexVM()
            {
                InstituteList = await _insRepo.GetAllAsync(SD.InstituteAPIPath, HttpContext.Session.GetString("JWToken")),
                EmployeeList  = await _employeeRepo.GetAllAsync(SD.EmployeeAPIPath, HttpContext.Session.GetString("JWToken")),
            };

            return(View(listOfInstitutesAndEmployees));
        }
예제 #3
0
 public async Task <IActionResult> GetAllInstitute()
 {
     return(Json(new { data = await _insRepo.GetAllAsync(SD.InstituteAPIPath, HttpContext.Session.GetString("JWToken")) }));
 }