public StudentResponse Create(StudentCreateRequest request) { Guid ID = _studentDao.InsertStudent(request); var response = new StudentResponse(_userService.Create(request, ID), request.Index, ID); return(response); }
public async Task <IActionResult> Create([FromBody] StudentCreateRequest request) { var contract = mapper.Map <StudentContract>(request); var id = await studentService.Create(contract); return(Ok(id)); }
public Guid InsertStudent(StudentCreateRequest student) { Create(); Guid ID = Guid.NewGuid(); using (connection) { SqlCommand command = new SqlCommand("INSERT INTO dbo.Student VALUES(@ID,@CreatedAt,@CreatedBy,@LastUpdatedAt,@LastUpdatedBy,@Index)", connection); command.Parameters.Add("@ID", SqlDbType.UniqueIdentifier); command.Parameters["@ID"].Value = ID; command.Parameters.Add("@Index", SqlDbType.VarChar); command.Parameters["@Index"].Value = student.Index; command.Parameters.Add("@LastUpdatedAt", SqlDbType.DateTime); command.Parameters["@LastUpdatedAt"].Value = DateTime.Now; command.Parameters.Add("@CreatedAt", SqlDbType.DateTime); command.Parameters["@CreatedAt"].Value = DateTime.Now; command.Parameters.Add("@LastUpdatedBy", SqlDbType.VarChar); command.Parameters["@LastUpdatedBy"].Value = "ivona"; command.Parameters.Add("@CreatedBy", SqlDbType.VarChar); command.Parameters["@CreatedBy"].Value = "ivona"; command.ExecuteNonQuery(); connection.Close(); } return(ID); }
public async Task <IActionResult> Create(StudentCreateRequest request) { var productId = await _studentService.Create(request); if (productId == 0) { return(BadRequest()); } return(RedirectToAction("Index")); }
public async Task <IActionResult> Create([FromForm] StudentCreateRequest request) { var studentId = await _manageStudentService.Create(request); if (studentId == 0) { return(BadRequest()); } var student = await _manageStudentService.GetById(studentId); return(CreatedAtAction(nameof(GetById), new { id = studentId }, student)); }
public async Task <int> Create(StudentCreateRequest request) { var province = _context.Provinces.First(x => x.ProvinceName == request.ProvinceName); var commune = _context.Communes.First(x => x.CommuneName == request.CommuneName); var district = _context.Districts.First(x => x.DistrictName == request.DistrictName); var student = new Student() { Name = request.Name, Yob = request.Yob, Address = request.Address + ", " + request.CommuneName + ", " + request.DistrictName + ", " + request.ProvinceName, Phone = request.Phone, DistrictId = district.DistrictId, ProvinceId = province.ProvinceId, CommuneId = commune.CommuneId }; _context.Students.Add(student); await _context.SaveChangesAsync(); return(student.Id); }
public async Task <ApiSuccessResponse> CreateAsync(StudentCreateRequest request) { var student = new Student() { Name = request.Name, Email = request.Email, RollNo = request.RollNo, DepartmentId = request.DepartmentId }; await _unitOfWork.StudentRepository.CreateAsync(student); if (await _unitOfWork.AppSaveChangesAsync()) { return(new ApiSuccessResponse() { StatusCode = 200, Message = "The student has been successfully created." }); } throw new MyAppException("Something went wrong!"); }
public StudentResponse Create(StudentCreateRequest request) { return(_studentService.Create(request)); }
public async Task <IActionResult> Create(StudentCreateRequest request) { return(Ok(await _studentService.CreateAsync(request))); }