/// <summary>
        /// Сохранить сущность.
        /// </summary>
        /// <param name="studentResearch">Сущность.</param>
        /// <returns>Идентификатор сущности.</returns>
        public int SaveStudentResearch(StudentResearch studentResearch)
        {
            Argument.NotNull(studentResearch, "Не указано руководство научной исследовательской работой студентов преподавателя.");
            var isEdit = studentResearch.StudentResearchId > 0;

            ValidateSave(studentResearch);

            using (IUnitOfWork unitOfWork = _unitOfWorkFactory.Create(_configuration))
            {
                if (isEdit)
                {
                    unitOfWork.StudentResearchRepository.Update(studentResearch);
                    return(studentResearch.StudentResearchId);
                }
                else
                {
                    return(unitOfWork.StudentResearchRepository.Insert(studentResearch));
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Сохранить учебник.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                var entity = new StudentResearch
                {
                    StudentResearchId = _studentResearchId,
                    PlanId            = _planId,
                    StudentName       = tbStudentName.Text,
                    StudentGroup      = tbStudentGroup.Text,
                    Research          = tbResearch.Text,
                    OopCode           = tbOopCode.Text,
                    Execution         = tbExecution.Text
                };
                _studentResearchService.SaveStudentResearch(entity);

                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 /// <summary>
 /// Удалить существующий экземпляр сущности.
 /// </summary>
 /// <param name="item">Модель экземпляра сущности.</param>
 public void Delete(StudentResearch item)
 {
     _dataContext.Connection.Delete(item, _dataContext.Transaction);
 }
 /// <summary>
 /// Валидация сохранения сущности.
 /// </summary>
 /// <param name="studentResearch">Сущность.</param>
 private void ValidateSave(StudentResearch studentResearch)
 {
     Argument.NotNull(studentResearch, "Не указано руководство научной исследовательской работой студентов преподавателя.");
     Argument.Require(studentResearch.PlanId > 0, "Не указан план учебной работы.");
 }
 /// <summary>
 /// Вставить новый экземпляр сущности.
 /// </summary>
 /// <param name="item">Модель нового экземпляра сущности.</param>
 /// <returns>Идентификатор нового экземпляра сущности.</returns>
 public int Insert(StudentResearch item)
 {
     return((int)_dataContext.Connection.Insert(item, _dataContext.Transaction));
 }