コード例 #1
0
ファイル: StudentController.cs プロジェクト: Alok-01/Triangle
        public async Task <IActionResult> Index(StudentRegistrationModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            try
            {
                var result = await this.ApiPostAsync(apiPostStudentUri, vm, "StudentApiClient");

                if (!result.IsSuccessStatusCode)
                {
                    ViewBag.Name = "Unable to Save At the Moment";
                    return(View(vm));
                }
                else
                {
                    ViewBag.Status = $"The student name { vm.StudentName } is record created! ";
                    RedirectToAction("studentlist", "student");
                    // return View(vm);
                }
            }
            catch (Exception ex)
            {
                LogSecurity.Warning("Exception on StudentRegistration Post : ", ex.InnerException.ToString());
                //return View(vm);
            }

            return(View(vm));
            //RedirectToAction("studentlist", "student");
        }
コード例 #2
0
ファイル: StudentController.cs プロジェクト: Alok-01/Triangle
        public async Task <IActionResult> CreateStudent(StudentRegistrationModel vm)
        {
            Log.Information("Authenticated user making student/secretcreatestudent API call.");
            ResponseModel <StudentRegistrationModel> response;

            if (ModelState.IsValid)
            {
                response = await _studentModelService.CreateStudent(vm);

                if (response.ReturnStatus == true)
                {
                    return(Ok(response));
                }
                else
                {
                    LogSecurity.Warning("Unauthorized access attempted Create {student}", vm.StudentName);
                    return(BadRequest(response));
                }
            }
            return(BadRequest(vm));
        }