Exemple #1
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddCors();
     //RSAEncryptionProvider.GenerateRSAKeysAndSave();
     IoCConfig.RegisterDependencies(services, Configuration);
     services.AddControllers().AddNewtonsoftJson();
 }
Exemple #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            IoCConfig.ConfigureServices(services);

            services.AddSwaggerDocument();
        }
Exemple #3
0
        protected override IKernel CreateKernel()
        {
            var kernel = new StandardKernel();

            IoCConfig.RegisterBindings(kernel);
            return(kernel);
        }
Exemple #4
0
        private void InjectAdapterSubstitute <TService>() where TService : class
        {
            var substitute = Substitute.For <TService>();

            IoCConfig.Inject(substitute);
            _adapterDependencies[typeof(TService)] = substitute;
        }
Exemple #5
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });

            IoCConfig.ConfigureEventBus(app);
        }
Exemple #6
0
 protected void Application_Start()
 {
     // Register Inversion of Control dependencies
     IoCConfig.RegisterDependencies();
     // Typical MVC setup
     // ....
 }
Exemple #7
0
        public ActionResult AddModel(dynamic model, Func <object, bool> pred = null)
        {
            if (ModelState.IsValid)
            {
                var managementItem = IoCConfig.Invoke_EntityManagementService(model);

                var adding_model = model.ToModel();
                //nếu gọi code trong hàm cha (AddDeal) thì phải cast sang kiểu con (Deal)
                //vd: var adding_model = model.ToModel() as Deal;
                if (adding_model == null)
                {
                    var error_msg = model.ErrorMessage != null ? model.ErrorMessage : "";
                    return(Error(error_msg));
                }

                //return managementItem.Add(adding_model);
                var res = managementItem.Add(adding_model);
                if (pred != null)
                {
                    pred(adding_model);
                }

                return(res);
            }

            return(Error());
        }
Exemple #8
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RouteConfig.RegisterRoutes(RouteTable.Routes);
            IoCConfig.RegisterDependencies();
        }
Exemple #9
0
        public ActionResult EditModel(dynamic model, Func <object, bool> pred = null)//model is new
        {
            if (ModelState.IsValid)
            {
                var managementItem = IoCConfig.Invoke_EntityManagementService(model);
                var service        = managementItem.GetService();
                var old            = service.FindById(model.Id);
                if (old == null)
                {
                    return(ErrorNotExist());
                }
                var adding_model = model.ToModel(old);
                //nếu gọi code trong hàm cha (AddDeal) thì phải cast sang kiểu con (Deal)
                //vd: var adding_model = model.ToModel() as Deal;
                if (adding_model == null)
                {
                    var error_msg = model.ErrorMessage != null ? model.ErrorMessage : "";
                    return(Error(error_msg));
                }

                //return managementItem.CheckAndEdit(adding_model);//update new to old
                var res = managementItem.CheckAndEdit(adding_model);
                if (pred != null)
                {
                    pred(adding_model);
                }

                return(res);
            }

            return(Error());
        }
        public ActionResult CheckAllAttendanceForDay(int id)
        {
            var day = IoCConfig.Service <IClass_Module_DayService>().FindById(id);

            if (IsValidModel(day))
            {
                foreach (var student in day.Class_Module_Day_Students)
                {
                    //student.Attendance_Status = (int)StudentClassModuleAttendanceEnum.P;
                    //student.Status = (int)EntityStatus.Visible;
                    student.Status = (int)EntityStatus.Invisible;
                }
                foreach (var student in day.Class_Module.Class_Module_StudentExams.Valid().Select(ex => ex.Student))
                {
                    day.Class_Module_Day_Students.Add(new Class_Module_Day_Student
                    {
                        Student_Id        = student.Id,
                        Attendance_Status = (int)StudentClassModuleAttendanceEnum.P,
                        Status            = (int)EntityStatus.Visible
                    });
                }

                return(EditModel(day));
            }

            return(Error());
        }
        public ActionResult ManageFeePlan_Detail(int?page, int id = 0)
        {
            //_partial_AddEdit_Course
            //_partial_Search_Course
            //return ManageModel(new CourseFamily(), null);

            IEnumerable <FeePlan_Detail> list = null;
            var currentParentName             = "";

            if (id == 0)
            {
                list = IoCConfig.Service <IFeePlan_DetailService>().FindAllValid();
            }
            else
            {
                var feeplan = IoCConfig.Service <IFeePlanService>().FindById(id);
                if (feeplan == null || !feeplan.IsValid())
                {
                    return(RedirectToError());
                }
                list = feeplan.FeePlan_Details.Valid();
                currentParentName = feeplan.FeePlan_Name;
            }

            return(ManageModel(new FeePlan_Detail {
                FeePlan_Id = id
            }, page,
                               list: list, entityName: "FeePlan Detail",
                               currentParentName: currentParentName,
                               currentParentId: id,
                               filterSearch: SearchModelEnum.None));
        }
        //ManageSchedule_ClassSession_Attendance
        public ActionResult ManageSchedule_ClassModule_Attendance(int?page, int id)
        {
            var current_classmodule = IoCConfig.Service <IClass_ModuleService>().FindById(id);

            if (current_classmodule == null || !current_classmodule.IsValid())
            {
                return(RedirectToError());
            }

            var currentParentName = GetClassModuleSmallText(current_classmodule);

            return(ManageModel(
                       new Class_Module_Day
            {
                Class_Module_Id = id,
                Class_Module_Day_Date = DateTime.Today,
                Class_Module_Day_Status = (int)ClassModuleDayStatusEnum.Scheduled,
                Status = (int)EntityStatus.Visible,
            }, page,
                       list: current_classmodule.Class_Module_Days.OrderBy(d => d.Class_Module_Day_Date).Valid(),
                       entityName: "Class Day",
                       currentParentModel: current_classmodule,
                       currentParentId: current_classmodule.Id, currentParentName: currentParentName,
                       breadcrumbpartial_name: "_partial_BreadCrumb_Class_Module_Day",
                       filterSearch: SearchModelEnum.None));
        }
        //ManageSchedule_ClassSession_Exam
        public ActionResult ManageSchedule_ClassModule_Exam(int?page, int id)
        {
            var current_classmodule = IoCConfig.Service <IClass_ModuleService>().FindById(id);

            if (current_classmodule == null || !current_classmodule.IsValid())
            {
                return(RedirectToError());
            }

            var currentParentName = GetClassModuleSmallText(current_classmodule);

            return(ManageModel(
                       new Class_Module_StudentExam
            {
                Class_Module_Id = id,
                Student_Status = (int)StudentClassModuleStatusEnum.Guest,
                Exam_Count = 1,
                Status = (int)EntityStatus.Visible,
            }, page,
                       list: GetClassModuleStudentExam(current_classmodule),
                       canAdd: false,
                       entityName: "Student Exam",
                       entityFilter: "Class_Module_Exam",
                       currentParentId: current_classmodule.Id, currentParentName: currentParentName,
                       //filterSearch: SearchModelEnum.ByOthers,
                       filterpartial_name: "_partial_Filter_Class_Module_StudentExam"));
        }
        private IEnumerable <Class_Module> GetClassModules(ref Class currentParent,
                                                           DateTime?start_date, DateTime?end_date, string class_name = "")
        {
            IEnumerable <Class_Module> list = null;

            if (class_name != "")
            {
                currentParent = IoCConfig.Service <IClassService>().FindByClassName(class_name);
                if (currentParent != null && currentParent.IsValid())
                {
                    list = currentParent.Class_Modules;
                }
            }
            else
            {
                list = IoCConfig.Service <IClass_ModuleService>().FindAllValid();
            }

            var start = DateTime.MinValue;
            var end   = DateTime.MaxValue;

            if (start_date.HasValue)
            {
                start = start_date.Value;
            }
            if (end_date.HasValue && start < end_date.Value)
            {
                end = end_date.Value;
            }

            return(list.Valid().Where(c => start <= c.Class_Module_Date_Start && c.Class_Module_Date_Start <= end)
                   .OrderByDescending(c => c.Class_Module_Date_Start));
        }
 private IEnumerable <User_Profile> GetEmployees()
 {
     return(IoCConfig.Service <IUserProfileService>()
            .FindAllValidByCriteria(e =>
                                    e.Role_Type_Id != (int)RoleTypeEnum.Admin)
            .OrderByDescending(a => a.Created_Date));
 }
        private User_Profile AddUserToDB(User_ProfileModel model)
        {
            //update User Profile
            var service = IoCConfig.Service <IUserProfileService>();

            var id   = model.Id;
            var user = new User_Profile();

            if (id != 0)
            {
                user = service.FindById(id);
                if (user == null)
                {
                    return(null);
                }
            }
            user = model.ToModel(user);
            if (user == null)
            {
                SetCustomError(model.ErrorMessage);
                return(null);//Trung phone va trung name thi khong cho add/edit
            }

            return(AddUserProfileToDB(user));
        }
Exemple #17
0
 public static IEnumerable <CourseFamily> CourseFamilies()
 {
     //return IoCConfig.Service<ICourseFamilyService>().FindAllValid();
     return(IoCConfig.Service <ICourseFamilyService>()
            .FindAllValidByCriteria(c => c.Course.Company_Type_Id == AuthenticationManager.Company_Type_Id)
            .OrderBy(c => c.Course.Course_Code));
 }
        /// <summary>
        /// Active user sau khi đăng ký thông qua key được gửi về email của user
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public ActionResult Active(string key)
        {
            //if (string.IsNullOrEmpty(key))
            //{
            //    return RedirectToError();
            //}

            var managementItem = new AccountManagementItem <User_Profile, IUserProfileService>();

            if (!managementItem.Active(this.ControllerContext, key))
            {
                return(RedirectToError(ACCOUNT_MSG_INVALIDACCOUNT));
            }
            var     AccountService = IoCConfig.Service <AccountService>();
            Account activeAcc      = AccountService.FindAll().Where(f => f.Account_ActiveKey == key).First();

            if (!CheckLoginAndAuthentication(activeAcc))
            {
                return(RedirectToLogin());
            }
            //var accountService = IoCConfig.Service<IAccountService>();
            //var account = accountService.GetAccountByActiveKey(key);
            //if (account == null)
            //{
            //    return RedirectToError(ACCOUNT_MSG_INVALIDACCOUNT);
            //}

            //accountService.Active(account);

            ////send email active thành công
            //EmailHelper.SendMail_RegisterActiveSuccess(this.ControllerContext, account);

            return(View());
        }
Exemple #19
0
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddSingleton(Configuration);
     IoCConfig.Initialize(services);
     services.AddCors();
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
 }
        public ActionResult LoginFacebook(string accessToken, string return_url)
        {
            var res = CheckLoginFacebook(accessToken);

            if (res.success == true)//thành công
            {
                var     user = res.user as User_Profile;
                Account acc  = null;
                //save session
                if (res.isNew == true)//nếu user mới
                {
                    user.SetRole(RoleTypeEnum.User);

                    //adding
                    var managementItem = new AccountManagementItem <User_Profile, IUserProfileService>();
                    managementItem.ModelState = ModelState;

                    acc = managementItem.AddingNonRegister(this.ControllerContext, user, true);
                }
                else//nếu user cũ
                {
                    acc = IoCConfig.Service <IAccountService>().GetAccountByProfileId(user.Id);
                }

                if (CheckLoginAndAuthentication(acc))
                {
                    return(Success());
                }
            }

            return(RedirectToLoginError(res.message));
        }
Exemple #21
0
        public void Setup()
        {
            if (!this._isIoCInit)
            {
                this.RegisterDependencies(FreshTinyIoCContainer.Current);
                IoCConfig.RegisterDependencies(FreshTinyIoCContainer.Current);

                this._isIoCInit = true;
            }

            if (!this._isMapperInit)
            {
                Mapper.Initialize(cfg =>
                {
                    this.RegisterMappers(cfg);
                    MapperConfig.RegisterMappers(cfg);
                });

                this._isMapperInit = true;
            }

            if (!this._isPageModelMapperInit)
            {
                FreshPageModelResolver.PageModelMapper = new PageModelMapper();

                this._isPageModelMapperInit = true;
            }
        }
        public override IEntity ToModel(IEntity _model) //edit: _model = old
        {
            var model = _model as Class_Module;         //old

            //check ton tai
            var existed = IoCConfig.Service <IClass_ModuleService>()
                          .FindValidByCriteria(c => c.Class_Id == this.Class_Id && c.Module_Id == this.Module_Id);

            if (existed != null)
            {
                ErrorMessage = "Lớp đã học môn này với FC " + existed.Faculty.FC_Name + " rồi!";
                return(null);
            }

            model.CopyModel(this);

            var class_id = model.Class_Id;

            if (class_id != null)
            {
                var current_class = IoCConfig.Service <IClassService>().FindById(class_id.Value);
                if (current_class != null && current_class.IsValid())
                {
                    model.GenerateSchedule(current_class);
                }
            }

            return(model);
        }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.Run(IoCConfig.Resolve <Form1>());
        }
Exemple #24
0
        public ActionResult Delete(U u)
        {
            var service = IoCConfig.Service <T>();

            service.Delete(u);
            return(Json(new { success = true, message = "Xóa thông tin thành công" }));
        }
Exemple #25
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configuration.DependencyResolver =
                new AutofacWebApiDependencyResolver(
                    IoCConfig.Build(Assembly.GetExecutingAssembly()));

            GlobalConfiguration.Configure(WebApiConfig.Register);
        }
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     IoCConfig.RegisterDependencies(BuildManager.GetReferencedAssemblies().Cast <Assembly>().ToArray());
 }
Exemple #27
0
        public ViewModelLocator()
        {
            var iocConfig = new IoCConfig();

            iocConfig.RegisterStores();
            iocConfig.RegisterActions();
            iocConfig.RegisterViewModels();
        }
Exemple #28
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     IoCConfig.Setup();
 }
Exemple #29
0
 protected void Application_Start()
 {
     IoCConfig.RegisterDependencies();
     AreaRegistration.RegisterAllAreas();
     AutoMapperConfiguration.Configure();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
Exemple #30
0
 protected Account GetCurrentAccount()
 {
     if (AuthenticationManager.IsAuthenticated)
     {
         return(IoCConfig.Service <IAccountService>().FindById(AuthenticationManager.Id));//.Clone() as User_Profile;
     }
     return(null);
 }