public bool Save(StudentEntity studnetEntity)
        {
            Student student;

              if (studnetEntity.Id == 0)
              {
            student = new Student();
              }
              else
              {
            student = _db.Students.SingleOrDefault(x=>x.Id == studnetEntity.Id);//1 hit
              }
              //mapping
              //poco == studnetEntity
              _db.Students.Add(student);
              _db.SaveChanges();
              return true;
        }
예제 #2
0
 public void Edit(StudentEntity student)
 {
     context.Entry(student).State = EntityState.Modified;
     context.SaveChanges();
 }
예제 #3
0
 public ActionResult Admission(StudentEntity studentEntity)
 {
     return(Json(new Student().AddStudent(studentEntity)));
 }
예제 #4
0
 public void Update(StudentEntity student)
 {
     context.Update <StudentEntity>(student);
     context.SaveChanges();
 }
 private Task <string[]> LoadImages(IEnumerable <StudentEntity> students)
 {
     return(Task.WhenAll(students.Select(entity =>
                                         this.PhotoService.DownloadPhoto(StudentEntity.CardUidToId(entity.CardUid)))));
 }
예제 #6
0
 Task IStudentRepository.CreateNewStudent(StudentEntity student)
 {
     throw new System.NotImplementedException();
 }
예제 #7
0
 public IActionResult Post([FromBody] StudentEntity studententity)
 {
     _studentServices.CreateStudent(studententity);
     return(Ok(studententity));
 }
        public static int insertStudent(StudentEntity se)
        {
            using (SqlConnection conn = new SqlConnection(Connection.getConnectionString()))
            {
                using (SqlCommand cmd = new SqlCommand("InsertStudent", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@Grno", se.grno);
                    cmd.Parameters.AddWithValue("@profile", se.ProfilePhoto);
                    cmd.Parameters.AddWithValue("@fullname", se.candidate_FirstName + " " + se.candidate_MiddleName + " " + se.candidate_LastName);
                    cmd.Parameters.AddWithValue("@gender", se.gender);
                    cmd.Parameters.AddWithValue("@admissiondate", se.AdmissionDate);
                    cmd.Parameters.AddWithValue("@castid", se.CastId);
                    cmd.Parameters.AddWithValue("@currentaddress", se.CurrentAddress);
                    cmd.Parameters.AddWithValue("@permanentaddress", se.PermanentAddress);
                    cmd.Parameters.AddWithValue("@pincode", se.Pincode);
                    cmd.Parameters.AddWithValue("@countryid", se.CountryId);
                    cmd.Parameters.AddWithValue("@stateid", se.StateId);
                    cmd.Parameters.AddWithValue("@cityid", se.CityId);
                    cmd.Parameters.AddWithValue("@dob", se.DOB);
                    cmd.Parameters.AddWithValue("@birthplace", se.BirthPlace);
                    cmd.Parameters.AddWithValue("@mobileno", se.MobileNo);
                    cmd.Parameters.AddWithValue("@telephone", se.TelephoneNo);
                    cmd.Parameters.AddWithValue("@email", se.Email);
                    cmd.Parameters.AddWithValue("@courseid", se.CourseId);
                    cmd.Parameters.AddWithValue("@coursenm", se.Coursenm);
                    cmd.Parameters.AddWithValue("@admissionsem", se.AdmissionSem);
                    cmd.Parameters.AddWithValue("@currentsem", se.CurrentSem);
                    cmd.Parameters.AddWithValue("@discount", se.Discount);
                    cmd.Parameters.AddWithValue("@fees", se.Fees);
                    cmd.Parameters.AddWithValue("@remark", se.Remark);
                    cmd.Parameters.AddWithValue("@currentstatus", se.CurrentStatus);
                    cmd.Parameters.AddWithValue("@leavingyear", se.LeavingYear);

                    cmd.Parameters.AddWithValue("@fathername", se.father_FirstName + " " + se.father_MiddleName + " " + se.father_LastName);
                    cmd.Parameters.AddWithValue("@mothername", se.mother_FirstName + " " + se.mother_MiddleName + " " + se.mother_LastName);
                    cmd.Parameters.AddWithValue("@parentsocupation", se.ParentsOccupation);
                    cmd.Parameters.AddWithValue("@parentsofficeaddress", se.OfficeAddress);
                    cmd.Parameters.AddWithValue("@parentscontectno", se.ContactNo);

                    cmd.Parameters.AddWithValue("@schoolname", se.SchoolName);
                    cmd.Parameters.AddWithValue("@schoolstream", se.SchoolStream);
                    cmd.Parameters.AddWithValue("@schoollastyear", se.LastYear);
                    cmd.Parameters.AddWithValue("@schoollastyearpercent", se.LastYear_Percentage);

                    cmd.Parameters.AddWithValue("@checkcollege", se.checkCollege);
                    cmd.Parameters.AddWithValue("@collegename", se.CollegeName);
                    cmd.Parameters.AddWithValue("@collegestream", se.CollegeStream);
                    cmd.Parameters.AddWithValue("@collegelastsem", se.LastSem);
                    cmd.Parameters.AddWithValue("@collegelastyear", se.CollegeYear);
                    cmd.Parameters.AddWithValue("@collegelastyearpercent", se.LastSem_Percentage);

                    cmd.Parameters.AddWithValue("@marksheet12", se.marksheet_12);
                    cmd.Parameters.AddWithValue("@lc", se.lc_12);
                    cmd.Parameters.AddWithValue("@previousmarksheet", se.previous_marksheet);
                    cmd.Parameters.AddWithValue("@noc", se.NOC);
                    cmd.Parameters.AddWithValue("@tc", se.TC);

                    cmd.Parameters.AddWithValue("@discountfee", ((se.Fees - ((se.Fees * se.Discount) / 100))));
                    cmd.Parameters.AddWithValue("@duefee", ((se.Fees - ((se.Fees * se.Discount) / 100))));


                    conn.Open();
                    return(cmd.ExecuteNonQuery());
                }
            }
        }
 public async Task Post([FromBody] StudentEntity student)
 {
     await _studentRepository.Create(student);
 }
예제 #10
0
 public bool UpdateStudent([FromBody] StudentEntity student)
 {
     return(studentService.UpdateStudent(student));
 }
예제 #11
0
 public bool CreateStudent(StudentEntity student)
 {
     return(studentService.CreateStudent(student));
 }
예제 #12
0
 public bool AddStudentFee(StudentEntity en)
 {
     return(dal.AddStudentFee(en));
 }
예제 #13
0
        /// <summary>
        /// To search a student record.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearch_Click(object sender, EventArgs e)
        {
            StudentEntity student = new StudentEntity();

            if (txtId.Text != string.Empty)
            {
                student.Id = Convert.ToInt32(txtId.Text);
                CheckStudentValidations studentValidations = new CheckStudentValidations();
                StudentEntity           studentResult      = new StudentEntity();
                studentResult = studentValidations.SearchStudentById(student);
                if (studentResult != null)
                {
                    txtName.Text = studentResult.Name;
                    txtAge.Text  = studentResult.Age.ToString();
                    if (studentResult.Gender == 'M' || studentResult.Gender == 'm')
                    {
                        radioGender1.Checked = true;
                    }
                    else
                    {
                        radioGender2.Checked = true;
                    }
                    txtId.Enabled = false;
                }
                else
                {
                    MessageBox.Show("No student with this id exists", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearFields();
                    txtId.Enabled = false;
                }
            }

            else if (txtName.Text != string.Empty)
            {
                student.Name = txtName.Text;
                CheckStudentValidations studentValidations = new CheckStudentValidations();
                StudentEntity           studentResult      = new StudentEntity();
                studentResult = studentValidations.SearchStudentByName(student);
                if (studentResult != null)
                {
                    if (studentResult.IsMultipleRecordExist)
                    {
                        txtId.Text   = studentResult.Id.ToString();
                        txtName.Text = studentResult.Name;
                        txtAge.Text  = studentResult.Age.ToString();
                        if (studentResult.Gender == 'M' || studentResult.Gender == 'm')
                        {
                            radioGender1.Checked = true;
                        }
                        else
                        {
                            radioGender2.Checked = true;
                        }
                        MessageBox.Show("Multiple Student Exists with name : " + studentResult.Name + ". If this is not the record you're looking for kindly search by student ID.", "Multiple Records", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtId.Enabled = true;
                    }
                    else
                    {
                        txtId.Text   = studentResult.Id.ToString();
                        txtName.Text = studentResult.Name;
                        txtAge.Text  = studentResult.Age.ToString();
                        if (studentResult.Gender == 'M' || studentResult.Gender == 'm')
                        {
                            radioGender1.Checked = true;
                        }
                        else
                        {
                            radioGender2.Checked = true;
                        }
                        txtId.Enabled = false;
                    }
                }
                else
                {
                    MessageBox.Show("No student with this Name exists", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearFields();
                    txtId.Enabled = false;
                }
            }

            else
            {
                MessageBox.Show("Fill Name to search!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #14
0
 public StudentFormToken(string title, [NotNull] StudentEntity student) :
     base(title)
 {
     this.Student = student;
 }
예제 #15
0
 public async Task Post([FromBody] StudentEntity student)
 {
     await _studsRepo.Insert_Student(student);
 }
예제 #16
0
 public async Task Update([FromRoute] string partitionKey, [FromRoute] string rowKey, [FromRoute] StudentEntity student)
 {
     await _studentRepository.Update(partitionKey, rowKey, student);
 }
        public DataResultArgs <StudentEntity> Set_Student(StudentEntity entity)
        {
            try
            {
                DataProcess.ControlAdminAuthorization(true);

                if (entity.Id > 0 && entity.DatabaseProcess == DatabaseProcess.Add)
                {
                    entity.DatabaseProcess = DatabaseProcess.Update;
                }

                DataResultArgs <StudentEntity> resultSet = new DataResultArgs <StudentEntity>();
                resultSet.Result = entity;

                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@DatabaseProcess", entity.DatabaseProcess);
                cmd.Parameters.AddWithValue("@id", entity.Id);
                cmd.Parameters.AddWithValue("@citizenshipNumber", entity.CitizenshipNumber);
                cmd.Parameters.AddWithValue("@name", entity.Name);
                cmd.Parameters.AddWithValue("@surname", entity.Surname);
                cmd.Parameters.AddWithValue("@middleName", entity.MiddleName);
                cmd.Parameters.AddWithValue("@fatherName", entity.FatherName);
                cmd.Parameters.AddWithValue("@motherName", entity.MotherName);
                cmd.Parameters.AddWithValue("@birthday", entity.Birthday);
                cmd.Parameters.AddWithValue("@fatherPhoneNumber", entity.FatherPhoneNumber);
                cmd.Parameters.AddWithValue("@motherPhoneNumber", entity.MotherPhoneNumber);
                cmd.Parameters.AddWithValue("@isActive", entity.IsActive);
                cmd.Parameters.AddWithValue("@isStudent", entity.IsStudent);
                cmd.Parameters.AddWithValue("@notes", entity.Notes);
                cmd.Parameters.AddWithValue("@dateOfMeeting", entity.DateOfMeeting);
                cmd.Parameters.AddWithValue("@spokenPrice", entity.SpokenPrice);
                cmd.Parameters.AddWithValue("@email", entity.Email);
                using (SqlConnection con = Connection.Conn)
                {
                    con.Open();
                    DataResultArgs <string> currentResultSet = DataProcess.ExecuteProcString(con, cmd, "set_Student");
                    con.Close();

                    resultSet.HasError         = currentResultSet.HasError;
                    resultSet.ErrorDescription = currentResultSet.ErrorDescription;
                    resultSet.MyException      = currentResultSet.MyException;

                    if (entity.DatabaseProcess == DatabaseProcess.Add && !currentResultSet.HasError)
                    {
                        resultSet.Result.Id = GeneralFunctions.GetData <Int32>(currentResultSet.Result);
                        entity.Id           = GeneralFunctions.GetData <Int32>(currentResultSet.Result);
                    }
                }


                if (entity.IsAddAfterPaymentUnPayment)
                {
                    List <PaymentTypeEntity> paymentTypeList = new PaymentTypeBusiness().Get_PaymentType();

                    foreach (PaymentTypeEntity paymentTypeEntity in paymentTypeList)
                    {
                        for (int i = 1; i < DateTime.Today.Month; i++)
                        {
                            PaymentEntity paymentEntity = new PaymentEntity();
                            paymentEntity.Id = 0;
                            paymentEntity.DatabaseProcess = DatabaseProcess.Add;
                            paymentEntity.Year            = (short)DateTime.Today.Year;
                            paymentEntity.StudentId       = entity.Id;
                            paymentEntity.IsNotPayable    = true;
                            paymentEntity.IsActive        = true;
                            paymentEntity.IsDeleted       = false;
                            paymentEntity.Month           = (short)i;
                            paymentEntity.IsPayment       = false;

                            paymentEntity.Amount =
                                ((PaymentTypeEnum)paymentTypeEntity.Id == PaymentTypeEnum.Okul &&
                                 entity.SpokenPrice.HasValue && entity.SpokenPrice.Value > 0)
                                    ? entity.SpokenPrice.Value
                                    : paymentTypeEntity.Amount;
                            paymentEntity.PaymentType = paymentTypeEntity.Id;
                            paymentEntity.AddedOn     = DateTime.Now;

                            new PaymentBusiness().Set_Payment(paymentEntity);
                        }
                    }
                }


                AllStudentWithCache = null;
                Get_AllStudentWithCache();

                return(resultSet);
            }
            catch (Exception e)
            {
                DataResultArgs <StudentEntity> result = new DataResultArgs <StudentEntity>();
                result.HasError         = true;
                result.ErrorDescription = e.Message;
                return(result);
            }
        }
        public StudentEntity Post([FromBody] StudentEntity student)
        {
            Students.Add(student.ToModel());

            return(student);
        }
        public void Save_WithAnExistingStudent_ExpectIndividualDalUpdateIsCalledOnce()
        {
            // Arrange
            var today = new DateTime(2003, 5, 17);

            const int ExpectedStudentId = 897931;
            var studentEntity = new StudentEntity { Id = ExpectedStudentId, };

            var stubStudentRepo = MockRepository.GenerateStub<IRepository<StudentEntity>>();
            stubStudentRepo
                .Stub(e => e.Retrieve(ExpectedStudentId))
                .Return(studentEntity);

            var mockIndividualRepo = MockRepository.GenerateStrictMock<IRepository<IndividualEntity>>();
            mockIndividualRepo
                .Expect(e => e.Update(Arg<IndividualEntity>.Is.Anything))
                .Repeat
                .Once();

            var classUnderTest =
                new Student(mockIndividualRepo, stubStudentRepo)
                {
                    Id = ExpectedStudentId,
                    Today = today,
                    DateOfBirth = today.AddYears(-19),
                };

            // Act
            classUnderTest.Save();

            // Assert
            Assert.AreEqual(ExpectedStudentId, classUnderTest.Id);
            mockIndividualRepo.VerifyAllExpectations();
        }
예제 #20
0
        public async Task CreateNewStudent(StudentEntity student)
        {
            var insertOperation = TableOperation.Insert(student);

            await _studentsTable.ExecuteAsync(insertOperation);
        }
예제 #21
0
 public void Update(StudentEntity student)
 {
     studentBusiness.Update(student);
 }
예제 #22
0
 public void DeleteStudent(StudentEntity student)
 {
     // Must be implemented
 }
예제 #23
0
 public int AddCourse(StudentEntity model)
 {
     students.Add(model);
     return(1);
 }
예제 #24
0
 public void Add(StudentEntity student)
 {
     context.Students.Add(student);
     context.SaveChanges();
 }
예제 #25
0
 public Task UpdateCourse(StudentEntity model)
 {
     throw new NotImplementedException();
 }
예제 #26
0
 public StudentEntity Update([FromBody] StudentEntity StudentEntity, [FromRoute] Guid StudentId)
 {
     return(StudentService.Update(UserEntity, StudentId, StudentEntity));
 }
 public StudentAdmission(StudentEntity se, SearchStudent obj1)
 {
     InitializeComponent();
     this.se          = se;
     searchstudentobj = obj1;
 }
예제 #28
0
        public IActionResult GetStudentById(int id)
        {
            StudentEntity student = _studentsRepo.GetById(id);

            return(Ok(student));
        }
        private void save_button_Click(object sender, EventArgs e)
        {
            if (!isPersonalDet_Validated)
            {
                AlertBox.ShowDialog("Please fill up Personal Detail", AlertBox.AlertType.error, false);
                studentadmission_tabControl.SelectedIndex = 0;
            }

            else if (educational_details_validation() /* && isPersonalDet_Validated*/)
            {
                #region entity
                StudentEntity se = new StudentEntity();
                se.grno                 = int.Parse(grno_textBox.Text);
                se.AdmissionDate        = admission_dateTimePicker.Value;
                se.ProfilePhoto         = ImagePath;
                se.candidate_FirstName  = candidatefnm_TextBox.Text;
                se.candidate_MiddleName = candidatemnm_TextBox.Text;
                se.candidate_LastName   = candidatelnm_TextBox.Text;
                se.gender               = (male_radioButton.Checked) ? male_radioButton.Text : female_radioButton.Text;
                se.CastId               = int.Parse(cast_comboBox.SelectedValue.ToString());
                se.CountryId            = int.Parse(country_comboBox.SelectedValue.ToString());
                se.StateId              = int.Parse(state_comboBox.SelectedValue.ToString());
                se.CityId               = int.Parse(city_comboBox.SelectedValue.ToString());
                se.CurrentAddress       = currentaddress_textbox.Text;
                se.PermanentAddress     = permanentaddress_textbox.Text;
                se.Pincode              = (pincode_TextBox.Text == string.Empty) ? (int?)null : int.Parse(pincode_TextBox.Text);
                se.BirthPlace           = birthplace_TextBox.Text;
                se.DOB           = dob_dateTimePicker.Value;
                se.MobileNo      = Int64.Parse(candidate_mno_textbox.Text);
                se.TelephoneNo   = (telephone_textbox.Text == string.Empty) ? (Int64?)null : Int64.Parse(telephone_textbox.Text);
                se.Email         = email_textbox.Text;
                se.CourseId      = int.Parse(admission_stream_combobox.SelectedValue.ToString());
                se.Coursenm      = admission_stream_combobox.Text;
                se.AdmissionSem  = int.Parse(admission_sem_numericUpDown.Value.ToString());
                se.CurrentSem    = int.Parse(admission_sem_numericUpDown.Value.ToString());
                se.Discount      = int.Parse(discount_numericUpDown.Value.ToString());
                se.Fees          = int.Parse(fees_to_pay_textbox.Text);
                se.Remark        = remark_textBox.Text;
                se.CurrentStatus = 'C';
                if (Convert.ToInt32(admission_sem_numericUpDown.Maximum) > 1)
                {
                    se.LeavingYear = admission_dateTimePicker.Value.Year + Convert.ToInt32(admission_sem_numericUpDown.Maximum / 2);
                }
                else
                {
                    int Mymonth = 0;
                    if ((admission_dateTimePicker.Value.Month + 6) > 12)
                    {
                        int InCurrentYear = 12 - admission_dateTimePicker.Value.Month;
                        int InNextYear    = 6 - InCurrentYear;
                        Mymonth = InNextYear;
                    }
                    else
                    {
                        Mymonth = admission_dateTimePicker.Value.Month + 6;
                    }
                    DateTime dt = new DateTime(admission_dateTimePicker.Value.Year, Mymonth, admission_dateTimePicker.Value.Day);
                    se.LeavingYear = dt.Year;
                }
                se.father_FirstName  = fatherfnm_TextBox.Text;
                se.father_MiddleName = fathermnm_TextBox.Text;
                se.father_LastName   = fatherlnm_TextBox.Text;

                se.mother_FirstName  = motherfnm_TextBox.Text;
                se.mother_MiddleName = mothermnm_TextBox.Text;
                se.mother_LastName   = motherlnm_TextBox.Text;

                se.ParentsOccupation = father_mother_occupation_textbox.Text;
                se.OfficeAddress     = office_address_textBox.Text;
                se.ContactNo         = Int64.Parse(parents_contact_TextBox.Text);

                se.SchoolName          = schoolnm_textbox.Text;
                se.SchoolStream        = school_stream_textbox.Text;
                se.LastYear            = int.Parse(school_year_textbox.Text);
                se.LastYear_Percentage = int.Parse(school_percent_textbox.Text);

                se.marksheet_12       = school_marksheet_CheckBox.Checked;
                se.lc_12              = school_LC_checkBox.Checked;
                se.TC                 = college_tc_checkBox.Checked;
                se.previous_marksheet = college_previous_marksheet_checkBox.Checked;
                se.NOC                = college_NOC_checkBox.Checked;

                if (college_checkBox.Checked)
                {
                    se.checkCollege       = true;
                    se.CollegeName        = collegenm_textbox.Text;
                    se.CollegeStream      = college_stream_textbox.Text;
                    se.CollegeYear        = int.Parse(college_year_textbox.Text);
                    se.LastSem            = int.Parse(college_last_sem_numericUpDown.Value.ToString());
                    se.LastSem_Percentage = int.Parse(college_percent_textbox.Text);
                }
                #endregion

                if (this.isUpdate)
                {
                    Student_Methods.deleteStudent_for_Update(int.Parse(grno_textBox.Text));
                }
                if (Student_Methods.insertStudent(se) > 0)
                {
                    if (isStore)
                    {
                        File.Copy(openphoto.FileName, ImagePath, true);
                        if (this.isUpdate)
                        {
                            student_pictureBox.Enabled = false;
                        }
                    }

                    if (!isUpdate)
                    {
                        AlertBox.ShowDialog("Successfull registered", AlertBox.AlertType.success, true);
                        clearAll(sender, e);
                        loadGrno();
                        admission_stream_combobox_SelectedIndexChanged(sender, e);
                    }
                    else
                    {
                        AlertBox.ShowDialog("Successfully updated", AlertBox.AlertType.success, true);
                        DataTable dt_student = Student_Methods.loadStudent();
                    }
                    studentadmission_tabControl.SelectedIndex = 0;
                }
            }
        }
예제 #30
0
 public void AddStudent(int courseId, StudentEntity student)
 {
     StudentRepositoryMock.StudentCollection.Add(student);
 }
예제 #31
0
        public ActionResult <IEnumerable <string> > Get()
        {
            string value2 = string.Empty;

            #region ========日志测试========
            //日志测试
            //LogUtil.Info("测试");
            #endregion

            #region ========Cache测试========
            //Cache测试
            //CacheUtil.Set("cachetest", "fwejio2123", new TimeSpan(0, 0, 10));//10s
            #endregion

            #region ========Session测试========
            //Session测试
            //SessionUtil.SetSession("test", "test");
            #endregion

            #region ========Cookie测试========
            //Cookie测试
            //CookieUtil.SetCookies("apirlcookietest", "这是个中文测试");
            #endregion

            #region ========SqlSugar测试========
            //StudentEntity entity = new StudentEntity();
            ////新增
            //entity.Name = "小明";
            //entity.Age = 18;
            //entity.Number = "007";
            //entity.Sex = 0;
            //entity.Address = "大洛阳";

            //_service.Insert(entity);

            //修改
            //SqlFilterEntity filter = new SqlFilterEntity();
            //filter.Append($"ID=@ID");
            //filter.Add("@ID", 1);
            //entity = _service.GetEntity(filter);
            //if (entity != null)
            //{
            //    //entity.Name = "我被修改了";
            //    //_service.Update(entity);

            //    _service.Delete(entity);
            //}

            #endregion

            #region ========Aop测试========
            _service.Test();
            #endregion

            #region ========企业微信测试========
            //企业微信信息发送
            //QyThridUtil.GetAccessToken();
            //MessageRange range = new MessageRange();
            //range.Users = new List<string>();
            //range.Users.Add("10001");
            //QyThridUtil.SendMessage("我就是来测试", range, AprilEnums.MessageType.Text);
            #endregion

            #region ========Redis测试========
            //添加
            StudentEntity student = new StudentEntity();
            student.ID      = 3;
            student.Name    = "小明";
            student.Number  = "201245";
            student.Sex     = 0;
            student.Age     = 18;
            student.Address = "洛阳市";
            RedisUtil.Add("student_1", student);
            //获取
            StudentEntity student1 = RedisUtil.Get <StudentEntity>("student_1");
            value2 = JsonConvert.SerializeObject(student1);
            //覆盖
            student.Name    = "小红";
            student.Age     = 16;
            student.Address = "不知道哪个村";
            student.Sex     = 1;
            RedisUtil.Replace("student_1", student);
            //删除
            RedisUtil.Remove("student_1");
            #endregion


            return(new string[] { "value1", value2 });
        }
예제 #32
0
 public async Task Update([FromRoute] string partitionKey, [FromRoute] string rowKey, [FromBody] StudentEntity student)
 {
     await _studsRepo.Update_Student(partitionKey, rowKey, student);
 }
        public void Save_WithAnExistingStudent_ExpectIndividualDalUpdateIsCalledOnce()
        {
            // Arrange
            var today = new DateTime(2003, 5, 17);

            const int ExpectedStudentId = 897931;
            var studentEntity = new StudentEntity { Id = ExpectedStudentId, };

            var stubStudentRepo = new Mock<IRepository<StudentEntity>>();
            stubStudentRepo
                .Setup(e => e.Retrieve(ExpectedStudentId))
                .Returns(studentEntity);

            var mockIndividualRepo = new Mock<IRepository<IndividualEntity>>();
            mockIndividualRepo
                .Setup(e => e.Update(It.IsAny<IndividualEntity>()));

            var classUnderTest =
                new Student(mockIndividualRepo.Object, stubStudentRepo.Object)
                {
                    Id = ExpectedStudentId,
                    Today = today,
                    DateOfBirth = today.AddYears(-19),
                };

            // Act
            classUnderTest.Save();

            // Assert
            Assert.AreEqual(ExpectedStudentId, classUnderTest.Id);
            mockIndividualRepo
                .Verify(e => e.Update(It.IsAny<IndividualEntity>()), Times.Once());
        }