Esempio n. 1
0
        public UpdateInstituteResponse Update(UpdateInstituteRequest request)
        {
            try
            {
                request.Validate();

                var institute = Institute.CreateInstance(request.Id, request.Title, request.Code, request.WebsiteUrl, request.IsActive, request.Description);
                this._unitOfWork.instituteRepository.Update(institute);
                this._unitOfWork.Commit();
                _busControl.Publish <RegisterInstituteEvent>(new RegisterInstituteEvent()
                {
                    CreateDate   = institute.CreateDate,
                    Description  = "Updated in CourseManagement module",
                    Id           = institute.Id,
                    IsActive     = institute.IsActive,
                    IsDeleted    = institute.IsDeleted,
                    ModifiedDate = institute.ModifyDate,
                    Title        = institute.Title
                });

                return(new UpdateInstituteResponse(true, "به روز رسانی با موفقیت انجام شد"));
            }
            catch (BusinessException e)
            {
                this._logger.Warning("Course Management-Institute Service-Update Institute ", e.Message);
                return(new UpdateInstituteResponse(false, "به روز رسانی با مشکل مواجه شد.", e.Message.ToString()));
            }
            catch (Exception e)
            {
                this._logger.Error("Course Management-Institute Service-Update Institute ", e.Message);
                return(new UpdateInstituteResponse(false, "به روز رسانی با مشکل مواجه شد.", e.Message.ToString()));
            }
        }
Esempio n. 2
0
        public async Task <bool> Do(RegisterInstituteEvent message)
        {
            try
            {
                Institute institute = _unitOfWork.instituteRepository.Get(message.Id);
                if (institute != null)
                {
                    institute.AssignDescription(message.Description);
                    institute.AssignIsActive(message.IsActive);
                    institute.AssignIsDeleted(message.IsDeleted);
                    institute.AssignModifiedDate(DateTime.Now);
                    institute.IncreaseRowVersion();
                    institute.AssignTitle(message.Title);

                    _unitOfWork.instituteRepository.Update(institute);
                    await _unitOfWork.CommitAsync();

                    return(true);
                }
                Institute newInstitute = Institute.CreateInstance(null, message.Title, message.IsActive, message.Description);

                await _unitOfWork.instituteRepository.AddAsync(newInstitute);

                await _unitOfWork.CommitAsync();

                return(true);
            }
            catch (Exception)
            {
                _unitOfWork.Dispose();
                return(false);
            }
        }
Esempio n. 3
0
        public void Seed(ModelBuilder modelBuilder)
        {
            var userSysAdmin = User.CreateInstance(DefaultData.SysAdminId, "Ali", "Jahanbin", DefaultData.SysAdminPassword, "*****@*****.**", DefaultData.SysAdminUsername, UserRoleEnum.SysAdmin, "09224957626", LevelEnum.Intermediate, true, string.Empty);
            var userTeacher  = User.CreateInstance(DefaultData.TeacherUserId, "Ali", "Jahanbin", DefaultData.TeacherPassword, "*****@*****.**", DefaultData.TeacherUsername, UserRoleEnum.Teacher, "09224957626", LevelEnum.Advanced, true, string.Empty);
            var userStudent  = User.CreateInstance(DefaultData.StudentId, "Ali", "Jahanbin", DefaultData.SysAdminPassword, "*****@*****.**", DefaultData.SysAdminUsername, UserRoleEnum.Student, "09224957626", LevelEnum.Begginer, true, string.Empty);

            var defaultInstitute = Institute.CreateInstance(DefaultData.InstituteId, "TestInstitute", Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), true, Guid.NewGuid().ToString());

            var defaultField = Field.CreateInstance(DefaultData.FieldId, "DefaultField", defaultInstitute.Id, true, string.Empty);

            var defaultCourse = Course.CreateInstance(DefaultData.CourseId, "DefaultCourse", AgeRangeEnum.Adults, defaultField.Id, true, string.Empty);

            var defaultTerm = Term.CreateInstance(DefaultData.TermId, "DefaultTerm", defaultCourse.Id, true, string.Empty);

            var defaultLessonPlan = LessonPlan.CreateInstance(DefaultData.LessonPlanId, LevelEnum.Begginer, DefaultData.SessionId, true, string.Empty);

            var defaultSession = Session.CreateInstance(DefaultData.SessionId, "DefaultSession", defaultLessonPlan.Id, defaultTerm.Id, true, string.Empty);

            var defaultPost = Post.CreateInstance(DefaultData.PostId, "DefaultPost", 1, ContentTypeEnum.Text, "Sample Content", defaultLessonPlan.Id, true, string.Empty);

            modelBuilder.Entity <Institute>().HasData(defaultInstitute);
            modelBuilder.Entity <Field>().HasData(defaultField);
            modelBuilder.Entity <Course>().HasData(defaultCourse);
            modelBuilder.Entity <Term>().HasData(defaultTerm);
            modelBuilder.Entity <LessonPlan>().HasData(defaultLessonPlan);
            modelBuilder.Entity <Session>().HasData(defaultSession);
            modelBuilder.Entity <Post>().HasData(defaultPost);
            modelBuilder.Entity <User>().HasData(userSysAdmin, userTeacher, userStudent);
        }
Esempio n. 4
0
        public AddInstituteResponse AddInstitute(AddInstituteRequest request)
        {
            try
            {
                request.Validate();

                this._instituteDomainService.CanAdd(request.Title);
                var institute = Institute.CreateInstance(null, request.Title, request.Code, request.WebsiteUrl, request.IsActive, request.Description);
                var address   = request.Address.Convert();
                institute.AssignAddress(address);
                this._unitOfWork.instituteRepository.Add(institute);
                this._unitOfWork.Commit();
                _busControl.Publish <RegisterInstituteEvent>(new RegisterInstituteEvent()
                {
                    CreateDate   = institute.CreateDate,
                    Description  = "Created in CourseManagement module",
                    Id           = institute.Id,
                    IsActive     = institute.IsActive,
                    IsDeleted    = institute.IsDeleted,
                    ModifiedDate = institute.ModifyDate,
                    Title        = institute.Title
                });

                return(new AddInstituteResponse(true, "ثبت با موفقیت انجام شد")
                {
                    NewRecordedId = institute.Id
                });
            }
            catch (BusinessException e)
            {
                this._logger.Warning("Course Management-Institute Service-Add Institute ", e.Message);
                return(new AddInstituteResponse(false, "ثبت با مشکل مواجه شد.", e.Message.ToString()));
            }
            catch (Exception e)
            {
                this._logger.Error("Course Management-Institute Service-Add Institute ", e.Message);
                return(new AddInstituteResponse(false, "ثبت با مشکل مواجه شد.", e.Message.ToString()));
            }
        }
Esempio n. 5
0
        public void Seed(ModelBuilder modelBuilder)
        {
            var defaultInstitute = Institute.CreateInstance(DefaultData.InstituteId, "TestInstitute", Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), true, Guid.NewGuid().ToString());

            var defaultField = Field.CreateInstance(DefaultData.FieldId, "DefaultField", defaultInstitute.Id, true, string.Empty);

            var defaultCourse = Course.CreateInstance(DefaultData.CourseId, "DefaultCourse", AgeRangeEnum.Adults, defaultField.Id, true, string.Empty);

            var defaultTerm = Term.CreateInstance(DefaultData.TermId, "DefaultTerm", defaultCourse.Id, true, string.Empty);

            var defaultLessonPlan = LessonPlan.CreateInstance(DefaultData.LessonPlanId, LevelEnum.Begginer, DefaultData.SessionId, true, string.Empty);

            var defaultSession = Session.CreateInstance(DefaultData.SessionId, "DefaultSession", defaultLessonPlan.Id, defaultTerm.Id, true, string.Empty);

            var defaultPost = Post.CreateInstance(DefaultData.PostId, "DefaultPost", 1, ContentTypeEnum.Text, Guid.NewGuid().ToString(), defaultLessonPlan.Id, true, string.Empty);

            modelBuilder.Entity <Institute>().HasData(defaultInstitute);
            modelBuilder.Entity <Field>().HasData(defaultField);
            modelBuilder.Entity <Course>().HasData(defaultCourse);
            modelBuilder.Entity <Term>().HasData(defaultTerm);
            modelBuilder.Entity <LessonPlan>().HasData(defaultLessonPlan);
            modelBuilder.Entity <Session>().HasData(defaultSession);
            modelBuilder.Entity <Post>().HasData(defaultPost);
        }