Exemple #1
0
 private HoaDonForm()
 {
     InitializeComponent();
     _hoaDonService    = UnityConfig.GetContainer().Resolve <IHoaDonService>();
     _khachHangService = UnityConfig.GetContainer().Resolve <IKhachHangService>();
     _sanPhamService   = UnityConfig.GetContainer().Resolve <ISanPhamService>();
 }
        public static void Register(HttpConfiguration config)
        {
            config.Services.Add(typeof(IExceptionLogger), new GlobalExceptionLogger());

            config.DependencyResolver = new UnityHierarchicalDependencyResolver(UnityConfig.GetContainer());

            config.EnableCors(new DefaultCorsPolicyProvider());

            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
            config.Filters.Add(new AuthorizeAttribute());
            config.Filters.Add(new AutoSaveChangesAttribute());

            // Use only JSON messages
            config.Formatters.Clear();
            var jsonFormatter = new JsonMediaTypeFormatter();

            jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            config.Formatters.Add(jsonFormatter);

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
Exemple #3
0
 public void Init()
 {
     using (var container = UnityConfig.GetContainer()) {
         _authService = container.Resolve <IAuthService>();
         _repository  = container.Resolve <IUserRepository>();
     }
 }
        //Service for making Payment with ADMIN
        public bool AdminPaymentService(PaymentRequest model)
        {
            string nonceFromTheClient = model.ExternalCardIdNonce;

            int currentTransactionId = 0;

            //Temporary code below
            ITransactionLogService _transactionLogService = UnityConfig.GetContainer().Resolve <ITransactionLogService>();

            currentTransactionId = _transactionLogService.BillingTransactionInsert(model);

            TransactionRequest request = new TransactionRequest
            {
                Amount             = model.ItemCost,
                PaymentMethodToken = nonceFromTheClient,
                Options            = new TransactionOptionsRequest
                {
                    SubmitForSettlement = true
                }
            };

            Result <Transaction> result = _Gateway.Transaction.Sale(request);

            var transactionJson = new JavaScriptSerializer().Serialize(result);

            //Instantiate values into Transaction Log Model
            BillingTransactionLog LogModel = new BillingTransactionLog();

            LogModel.Id          = currentTransactionId;
            LogModel.RawResponse = transactionJson;


            if (result.Message == null && result.Errors == null)
            {
                //Instatiate Success Values
                LogModel.AmountConfirmed    = result.Target.Amount;
                LogModel.TransactionId      = result.Target.Id;
                LogModel.CardExpirationDate = result.Target.CreditCard.ExpirationDate;
                LogModel.CardLastFour       = result.Target.CreditCard.LastFour;

                ActivityLogRequest Activity = new ActivityLogRequest();

                Activity.ActivityType = ActivityTypeId.MadePayment;


                _ActivityLogService.InsertActivityToLog(model.UserId, Activity);



                return(_transactionLogService.TransactionLogUpdateSuccess(LogModel));
            }
            else
            {
                //Instatiate Error Values
                LogModel.ErrorCode = result.Message;

                bool response = _transactionLogService.TransactionLogUpdateError(LogModel);
                throw new System.ArgumentException(result.Message, "CreditCard");
            }
        }
        public void Configuration(IAppBuilder app)
        {
            var identityService = UnityConfig.GetContainer().Resolve <IIdentityService>();

            app.UseOAuthAuthorizationServer(new OAuthOptions(identityService));
            app.UseJwtBearerAuthentication(new JwtOptions());
            app.UseCors(CorsOptions.AllowAll);
            app.MapSignalR();
        }
Exemple #6
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            config.DependencyResolver = new UnityResolver(UnityConfig.GetContainer());

            GlobalConfiguration.Configuration.Formatters.JsonFormatter.MediaTypeMappings
            .Add(new RequestHeaderMapping("Accept",
                                          "text/html",
                                          StringComparison.InvariantCultureIgnoreCase,
                                          true,
                                          "application/json"
                                          ));
            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
        public Task ValidateIdentity(OAuthValidateIdentityContext context)
        {
            context.Rejected();

            Guid userSessionToken;

            if (JwtHelper.TryGetUserSessionToken(context.Ticket.Identity, out userSessionToken))
            {
                using (var container = UnityConfig.GetContainer().CreateChildContainer())
                {
                    var userSessionBusinessLogic = (IUserSessionBusinessLogic)container.Resolve(typeof(IUserSessionBusinessLogic));

                    var isValid = userSessionBusinessLogic.GetIsUserSessionValid(userSessionToken);
                    if (isValid)
                    {
                        context.Validated();
                    }
                }
            }

            return(Task.CompletedTask);
        }
Exemple #8
0
        public void Start()
        {
            lock (_lockObject)
            {
                if (_started)
                {
                    return;
                }
                _started = true;


                HostingEnvironment.RegisterObject(this);
                GlobalConfiguration.Configuration
                .UseSqlServerStorage(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)
                .UseUnityActivator(UnityConfig.GetContainer())
                .UseConsole();



                _backgroundJobServer = new BackgroundJobServer();
            }
        }
 private SanPhamForm()
 {
     InitializeComponent();
     _sanPhamService = UnityConfig.GetContainer().Resolve <ISanPhamService>();
 }
Exemple #10
0
 private KhachHangForm()
 {
     InitializeComponent();
     _khachHangService = UnityConfig.GetContainer().Resolve <IKhachHangService>();
 }
        public BaseController(ISiteConfig config)
        {
            SiteConfig = config;

            _container = UnityConfig.GetContainer();
        }
        public BaseController()
        {
            _container = UnityConfig.GetContainer();

            SiteConfig = _container.Resolve <ISiteConfig>();
        }