Пример #1
0
        public async Task <int> InsertOrder(Order order)
        {
            int result = 0;

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    result = await ds.ExecuteNonQuery("usp_InsertOrder",
                                                      ds.CreateParameter("UserID", order.UserID),
                                                      ds.CreateParameter("PaymentStatusID", order.PaymentStatusID),
                                                      ds.CreateParameter("TransactionID", order.TransactionID),
                                                      ds.CreateParameter("TrackingNumber", order.TrackingNumber),
                                                      ds.CreateParameter("SubTotal", order.SubTotal),
                                                      ds.CreateParameter("OrderTotal", order.OrderTotal),
                                                      ds.CreateParameter("Tax", order.Tax),
                                                      ds.CreateParameter("ShippingCharges", order.ShippingCharges),
                                                      ds.CreateParameter("OrderDate", order.OrderDate),
                                                      ds.CreateParameter("DeliveryDate", order.DeliveryDate),
                                                      ds.CreateParameter("SpecialInstruction", order.SpecialInstruction));
                }
            }
            catch (Exception)
            {
                return(0);
            }

            return(result);
        }
        public void HelloWorldWrite(String message)
        {
            DataSourceFactory dsf           = new DataSourceFactory();
            ISource           currentSource = dsf.CreateDataSource();

            currentSource.WriteMessage(message);
        }
Пример #3
0
        public async Task <int> InsertDeliveryAddress(DeliveryAddress deliveryAddress)
        {
            int result = 0;

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    result = await ds.ExecuteNonQuery("usp_InsertDeliveryAddress",
                                                      ds.CreateParameter("UserID", deliveryAddress.UserID),
                                                      ds.CreateParameter("OrderID", deliveryAddress.OrderID),
                                                      ds.CreateParameter("Name", deliveryAddress.Name),
                                                      ds.CreateParameter("Pincode", deliveryAddress.Pincode),
                                                      ds.CreateParameter("Address", deliveryAddress.Address),
                                                      ds.CreateParameter("Landmark", deliveryAddress.Landmark),
                                                      ds.CreateParameter("country", deliveryAddress.country),
                                                      ds.CreateParameter("state", deliveryAddress.state),
                                                      ds.CreateParameter("city", deliveryAddress.city),
                                                      ds.CreateParameter("phone", deliveryAddress.phone));
                }

                return(result);
            }
            catch (Exception)
            {
                return(0);
            }
        }
        public string HelloWorld()
        {
            DataSourceFactory dsf           = new DataSourceFactory();
            ISource           currentSource = dsf.CreateDataSource();

            String message = currentSource.GetMessage();

            return(message);
        }
Пример #5
0
    public void ProvideSubtitleForVideo(Video video)
    {
        try
        {
            var message = string.Format("Finding subtitle for {0}", video.Name);
            InformUser(message);

            var dataSource           = DataSourceFactory.CreateDataSource();
            var blackListingProvider = new BlackListingProvider(video, dataSource);
            var subtitleSelector     = new SubtitleSelector(blackListingProvider);

            var languageProvider = new LanguageProvider();
            var languages        = languageProvider.CreateLanguageCollectionFromString(Plugin.PluginOptions.Instance.Languages);
            var finder           = new RemoteSubtitleFinder(video, subtitleSelector);
            var subtitle         = finder.FindSubtitle(languages, blackListingProvider);

            if (subtitle == null)
            {
                var failureMessage = string.Format("Downloading subtitle failed. No subtitle found for {0}", video.Name);
                InformUser(failureMessage);
                return;
            }

            var filePath = Path.Combine(ApplicationPaths.AppCachePath, Path.GetRandomFileName() + ".zip");

            var subtitleDownloader = new SubtitleDownloader();
            subtitleDownloader.GetSubtitleToPath(subtitle, filePath);

            var subtitleExtractorFactory = new SubtitleExtractorFactory();
            var subtitleExtractor        = subtitleExtractorFactory.CreateSubtitleExtractorByVideo(video);

            try
            {
                subtitleExtractor.ExtractSubtitleFile(filePath);
            }
            catch (InvalidSubtitleFileException)
            {
                blackListingProvider.BlackList(subtitle);
                throw new Exception("Invalid subtitle file, blacklisting: " + subtitle.UrlToFile);
            }

            dataSource.SetCurrentSubtitle(video, subtitle);
            var successMessage = string.Format("Subtitle downloaded for {0} - {1}", video.Name, subtitle.Langugage);
            InformUser(successMessage);
        }
        catch (Exception ex)
        {
            var reportedError =
                string.Format("Error when getting subtitle for video: {0}.", video.Name);

            InformUser(reportedError);

            Logger.ReportException(reportedError, ex);
        }
    }
Пример #6
0
    private static void HandleBlackListing(Video video)
    {
        var dataSource = DataSourceFactory.CreateDataSource();
        var subtitle   = dataSource.GetCurrentSubtitle(video);

        var blackListingProvider = new BlackListingProvider(video);

        blackListingProvider.BlackList(subtitle);

        HandleDownloadSubtitle(video);
    }
Пример #7
0
        public async Task <User> GetUserByID(int id)
        {
            User user = new User();

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    user = await ds.GetResult <User>("usp_GetUserByID", ds.CreateParameter("UserID", id));
                }
            }
            catch (Exception)
            {
            }

            return(user);
        }
Пример #8
0
        public async Task <List <User> > GetAllUsers()
        {
            List <User> userList = new List <User>();

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    userList = await ds.GetResults <User>("usp_GetAllUsers");
                }
            }
            catch (Exception)
            {
            }

            return(userList);
        }
Пример #9
0
        public async Task <List <Order> > GetAllOrders()
        {
            List <Order> orderList = new List <Order>();

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    orderList = await ds.GetResults <Order>("usp_GetAllOrders");
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(orderList);
        }
Пример #10
0
        public async Task <List <DeliveryAddress> > GetDeliveryAddressByUserID(int id)
        {
            List <DeliveryAddress> deliveryAddresses = new List <DeliveryAddress>();

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    deliveryAddresses = await ds.GetResults <DeliveryAddress>("usp_GetDeliveryAddressByUserID", ds.CreateParameter("UserID", id));
                }

                return(deliveryAddresses);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Пример #11
0
        public async Task <DeliveryAddress> GetDeliveryAddressByOrderID(int id)
        {
            DeliveryAddress deliveryAddress = new DeliveryAddress();

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    deliveryAddress = await ds.GetResult <DeliveryAddress>("usp_GetDeliveryAddressByOrderID", ds.CreateParameter("OrderID", id));

                    return(deliveryAddress);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Пример #12
0
        public async Task <List <DeliveryAddress> > GetAllDeliveryAddress()
        {
            List <DeliveryAddress> deliveryAddresses = new List <DeliveryAddress>();

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    deliveryAddresses = await ds.GetResults <DeliveryAddress>("usp_GetAllDeliveryAddress", null);
                }

                return(deliveryAddresses);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public async Task <List <OrderProduct> > GetOrderProductByOrderID(int id)
        {
            List <OrderProduct> orderProducts = new List <OrderProduct>();

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    orderProducts = await ds.GetResults <OrderProduct>("usp_GetOrderProduct", ds.CreateParameter("OrderID", id));
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(orderProducts);
        }
Пример #14
0
        public async Task <Order> GetOrderByID(int id)
        {
            Order order = new Order();

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    order = await ds.GetResult <Order>("usp_GetOrderByID", ds.CreateParameter("OrderID", id));
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(order);
        }
Пример #15
0
        public async Task <int> DeleteUser(int id)
        {
            int result = 0;

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    result = await ds.ExecuteNonQuery("usp_DeleteUser", ds.CreateParameter("UserId", id));
                }
            }
            catch (Exception)
            {
                return(0);
            }

            return(result);
        }
Пример #16
0
        public async Task <int> UpdateUser(User user)
        {
            int result = 0;

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    result = await ds.ExecuteNonQuery("usp_UpdateUser",
                                                      ds.CreateParameter("UserId", user.UserId),
                                                      ds.CreateParameter("FirstName", user.FirstName),
                                                      ds.CreateParameter("LastName", user.LastName),
                                                      ds.CreateParameter("DateOfBirth", user.DateOfBirth),
                                                      ds.CreateParameter("EmailID", user.UserId),
                                                      ds.CreateParameter("Gender", user.Gender),
                                                      ds.CreateParameter("CompanyName", user.CompanyName),
                                                      ds.CreateParameter("StreetAddress1", user.StreetAddress1),
                                                      ds.CreateParameter("StreetAddress2", user.StreetAddress2),
                                                      ds.CreateParameter("PostCode", user.PostCode),
                                                      ds.CreateParameter("City", user.City),
                                                      ds.CreateParameter("StateId", user.StateId),
                                                      ds.CreateParameter("Country", user.Country),
                                                      ds.CreateParameter("Phone", user.Phone),
                                                      ds.CreateParameter("Fax", user.Fax),
                                                      ds.CreateParameter("Password", user.Password),
                                                      ds.CreateParameter("IsTaxExempt", user.IsTaxExempt),
                                                      ds.CreateParameter("IsAdmin", user.IsAdmin),
                                                      ds.CreateParameter("AdminComment", user.AdminComment),
                                                      ds.CreateParameter("Status", user.Status),
                                                      ds.CreateParameter("RegistrationDate", user.RegistrationDate),
                                                      ds.CreateParameter("OrderUser", user.OrderUser),
                                                      ds.CreateParameter("IsEmailValidated", user.IsEmailValidated),
                                                      ds.CreateParameter("UpdateDate", user.UpdateDate));
                }
            }
            catch (Exception ex)
            {
                return(0);
            }

            return(result);
        }
        public async Task <int> InsertOrderProduct(OrderProduct orderProduct)
        {
            int result = 0;

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    result = await ds.ExecuteNonQuery("usp_InsertOrderProduct",
                                                      ds.CreateParameter("ProductID", orderProduct.ProductId),
                                                      ds.CreateParameter("OrderID", orderProduct.OrderId),
                                                      ds.CreateParameter("Price", orderProduct.Price),
                                                      ds.CreateParameter("Quantity", orderProduct.Quantity));
                }
            }
            catch (Exception)
            {
                return(0);
            }

            return(result);
        }