public List <NewStudentModel> search(string key) { SqlCommand com_search = new SqlCommand("proc_searchstudent", con); com_search.Parameters.AddWithValue("@key", key); com_search.CommandType = CommandType.StoredProcedure; con.Open(); SqlDataReader dr = com_search.ExecuteReader(); List <NewStudentModel> list = new List <NewStudentModel>(); while (dr.Read()) { NewStudentModel model = new NewStudentModel(); model.StudentID = dr.GetInt32(0); model.StudentName = dr.GetString(1); model.StudentEmailId = dr.GetString(2); model.StudentPassword = dr.GetString(3); model.StudentCity = dr.GetString(4); model.StudentAddress = dr.GetString(5); model.StudentDOB = dr.GetDateTime(6); model.StudentMobileNo = dr.GetString(7); model.StudentImage = dr.GetString(8); list.Add(model); } con.Close(); return(list); }
public async Task <StudentsModel> CreateNewStudent(NewStudentModel request, byte[] imageBytes) { var student = new StudentsEntityModel { FirstName = request.FirstName, SecondName = request.SecondName, Patronymic = request.Patronymic, InstitutionId = request.InstitutionId, Status = Status.New, FilingDate = DateTime.Now.Date, Email = request.Email, Phone = request.Phone, PracticArea = request.PracticArea, Speciality = request.Speciality, PractiesBegining = request.PractiesBegining, PractiesEnding = request.PractiesEnding }; var result = _studRepository.CreateStudent(student, imageBytes); if (result == null) { return(result); } var mailSubject = "Заявка на практику"; var mailBody = "Ваша заявка была успешно оформлена. Ожидайте ответа на указанный вами номер телефона, либо почту."; var mailRequest = _requestClient.Create(new { To = request.Email, Body = mailBody, Subject = mailSubject }); var responce = await mailRequest.GetResponse <IEmailSent>(); _logger.LogInformation($"Email succefully sent! ID:{responce.Message.EventId} Time:{responce.Message.SentAtUtc}"); return(result); }
protected void btn_newstudent_Click(object sender, EventArgs e) { LibraryDAL dal = new LibraryDAL(); NewStudentModel model = new NewStudentModel(); model.StudentName = txt_studentname.Text; model.StudentEmailId = txt_studentemailid.Text; model.StudentPassword = txt_studentpassword.Text; model.StudentCity = txt_studentcity.Text; model.StudentAddress = txt_studentaddress.Text; model.StudentDOB = Convert.ToDateTime(txt_studentdob.Text); model.StudentMobileNo = txt_studentMobileNo.Text; model.StudentImage = "~/Images/" + Guid.NewGuid() + ".jpg"; file_StudentImage.SaveAs(Server.MapPath(model.StudentImage)); int id = dal.AddStudent(model); lbl_msg.Text = "Student Added : " + id; }
public IActionResult CreateNewStudent([FromForm] NewStudentModel request, IFormFile photo) { try { var imageBytes = _fileService.ImageToBytes(photo); var result = _studentService.CreateNewStudent(request, imageBytes); if (result == null) { return(BadRequest("Такой студент уже существует")); } _logger.LogInformation($"Успешное добавление студента в базу: {result}"); return(Ok(result)); } catch (Exception ex) { _logger.LogError(ex, $"Ошибка при добавлении студента {request}"); return(BadRequest(ex)); } }
public int AddStudent(NewStudentModel model) { SqlCommand com_addstudent = new SqlCommand("proc_addstudent", con); com_addstudent.Parameters.AddWithValue("@name", model.StudentName); com_addstudent.Parameters.AddWithValue("@emailid", model.StudentEmailId); com_addstudent.Parameters.AddWithValue("@password", model.StudentPassword); com_addstudent.Parameters.AddWithValue("@city", model.StudentCity); com_addstudent.Parameters.AddWithValue("@address", model.StudentAddress); com_addstudent.Parameters.AddWithValue("@dob", model.StudentDOB); com_addstudent.Parameters.AddWithValue("@mobileno", model.StudentMobileNo); com_addstudent.Parameters.AddWithValue("@image", model.StudentImage); com_addstudent.CommandType = CommandType.StoredProcedure; SqlParameter para_ret = new SqlParameter(); para_ret.Direction = ParameterDirection.ReturnValue; com_addstudent.Parameters.Add(para_ret); con.Open(); com_addstudent.ExecuteNonQuery(); con.Close(); int id = Convert.ToInt32(para_ret.Value); return(id); }