Esempio n. 1
0
        public ActionResult Index()
        {
            var result = new APIConsumer().ConsumeAPI();

            TempData["Result"] = result.Result;
            return(View());
        }
Esempio n. 2
0
        public ActionResult Edit(Invoice invoice)
        {
            try
            {
                // TODO: Add update logic here
                invoice = APIConsumer <Invoice> .GetObject(PATH, invoice.Id.ToString());

                if (invoice.IsPaid == false)
                {
                    invoice.IsPaid = true;
                }
                else
                {
                    invoice.IsPaid = false;
                }

                APIConsumer <Models.Webshop.Invoice> .EditObject(PATH, invoice.Id.ToString(), invoice);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 3
0
        public ActionResult Edit(Product product)
        {
            if (product.EndDate < product.StartDate)
            {
                ModelState.AddModelError("EndDate", "Einddatum moet groter dan startdatum zijn");
            }
            else if (product.StartDate < DateTime.Today)
            {
                ModelState.AddModelError("StartDate", "Startdatum moet groter dan dag van vandaag zijn");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    // TODO: Add update logic here
                    APIConsumer <Models.Webshop.Product> .EditObject(PATH, product.Id.ToString(), product);

                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }

            return(View());
        }
    public static void GET_BankInfoBasicByRN(SqlString URL, SqlString rn)
    {
        try
        {
            var    BankInfoResult = new BankInfoBasic();
            string Result         = APIConsumer.GETMethod <BankInfoBasic>(URL.ToString(), rn.ToString(), ref BankInfoResult);

            var Header = new SqlMetaData[]
            {
                new SqlMetaData(nameof(BankInfoResult.Code), SqlDbType.VarChar, 100),
                new SqlMetaData(nameof(BankInfoResult.Name), SqlDbType.VarChar, 50),
                new SqlMetaData(nameof(BankInfoResult.Message), SqlDbType.VarChar, 100),
                new SqlMetaData(nameof(BankInfoResult.rn), SqlDbType.VarChar, 100),
            };

            Helper.SendResults(Header
                               , BankInfoResult.Code
                               , BankInfoResult.Name
                               , BankInfoResult.Message
                               , BankInfoResult.rn
                               );
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message.ToString());
        }
    }
Esempio n. 5
0
        public ActionResult Create(Product product)
        {
            if (product.EndDate < product.StartDate)
            {
                ModelState.AddModelError("EndDate", "Einddatum moet groter dan startdatum zijn");
            }
            else if (product.StartDate < DateTime.Today)
            {
                ModelState.AddModelError("StartDate", "Startdatum moet groter of gelijk zijn dan vandaag");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    ProductPrice productPrice = new ProductPrice(product.Price, product.StartDate, product.EndDate);
                    APIConsumer <ProductPrice> .AddObject("productprice", productPrice);

                    APIConsumer <Models.Webshop.Product> .AddObject(PATH, product);

                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }

            return(View());
        }
Esempio n. 6
0
        // GET: Product/Details/5

        public ActionResult Details(int id)
        {
            Product product = APIConsumer <Product> .GetObject("product", id.ToString());

            IEnumerable <Course> courses = this.courses.Where(i => i.ProductId == product.Id);

            product.Courses = courses.ToList();
            return(View(product));
        }
Esempio n. 7
0
        static IEnumerable <Response> GetLatestResults()
        {
            var loteriasApiConfig = new LoteriasAPIConfig("https://apiloterias.com.br/");
            var accessConfig      = new AccessConfig("megasena", "yourTokenHere");
            var apiConsumer       = new APIConsumer(accessConfig, loteriasApiConfig);
            var start             = 2275;
            var end    = 2329;
            var result = apiConsumer.GetResults(start, end);

            return(result);
        }
Esempio n. 8
0
        private async Task LoadRecipesAsync()
        {
            IsLoading = true;
            Recipes   = await APIConsumer.GetRecipesAsync();

            foreach (var recipe in Recipes)
            {
                recipe.LoadChildrenCommand.Execute(null);
            }
            IsLoading = false;
        }
        public async Task <IActionResult> JSEndpoint(int id)
        {
            APIConsumer externalAPI     = new APIConsumer();
            string      requestedRecord = await externalAPI.ReadAsync(id);

            APIResponseModel externalResponse = new APIResponseModel();

            externalResponse.APIResponse = requestedRecord + "(Passed through JS endpoint controller, rather than direct from JQuery, x1)";

            return(View("JSEndpoint", externalResponse));
        }
Esempio n. 10
0
        public MyOrderController()
        {
            invoices = APIConsumer <Invoice> .GetAPI("invoice");

            details = APIConsumer <InvoiceDetail> .GetAPI("invoicedetail");

            activeInvoices = new List <Invoice>();
            user           = System.Web.HttpContext.Current.GetOwinContext()
                             .GetUserManager <ApplicationUserManager>()
                             .FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());
        }
Esempio n. 11
0
    public static void APICaller_GET_JsonBody_Header(SqlString URL, SqlString JsonBody, SqlString Headers)
    {
        try
        {
            string Result = APIConsumer.GETMethod_Headers(URL.ToString(), JsonBody.ToString(), Headers.ToString());

            Helper.SendResultValue("Result", Result);
        }
        catch (Exception ex)
        {
            Helper.SendResultValue("Error", ex.Message.ToString());
        }
    }
Esempio n. 12
0
    public static void APICaller_GET_Auth(SqlString URL, SqlString Authorization)
    {
        try
        {
            string Result = APIConsumer.GETMethod(URL.ToString(), Authorization.ToString());

            Helper.SendResultValue("Result", Result);
        }
        catch (Exception ex)
        {
            Helper.SendResultValue("Error", ex.Message.ToString());
        }
    }
Esempio n. 13
0
        public ActionResult Delete(Course course)
        {
            try
            {
                APIConsumer <Models.Webshop.Course> .DeleteObject("course", (course.Id).ToString(), course);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
    public static void APICaller_POST(SqlString URL, SqlString JsonBody)
    {
        try
        {
            string Result = APIConsumer.POSTMethod(URL.ToString(), JsonBody.ToString());

            Helper.SendResultValue("Result", Result);
        }
        catch (Exception ex)
        {
            Helper.SendResultValue("Error", ex.Message.ToString());
        }
    }
    public static void APICaller_POST_FORM_ENCODED(SqlString URL, SqlString scopeURL, SqlString client_id, SqlString client_secret)
    {
        try
        {
            string Result = APIConsumer.POSTMethod_UrlEncoded(URL.ToString(), scopeURL.ToString(), client_id.ToString(), client_secret.ToString());

            Helper.SendResultValue("Result", Result);
        }
        catch (Exception ex)
        {
            Helper.SendResultValue("Error", ex.Message.ToString());
        }
    }
Esempio n. 16
0
        public ActionResult Create(Vat vat)
        {
            try
            {
                // TODO: Add insert logic here
                APIConsumer <Models.Webshop.Vat> .AddObject(PATH, vat);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 17
0
        public ActionResult Delete(Product product)
        {
            try
            {
                // TODO: Add delete logic here
                APIConsumer <Models.Webshop.Product> .DeleteObject(PATH, (product.Id).ToString(), product);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 18
0
        public ActionResult Edit(Vat vat)
        {
            try
            {
                // TODO: Add update logic here
                APIConsumer <Models.Webshop.Vat> .EditObject(PATH, vat.Id.ToString(), vat);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 19
0
        public ActionResult Delete(InvoiceDetail invoiceDetail)
        {
            try
            {
                // TODO: Add delete logic here
                APIConsumer <Models.Webshop.InvoiceDetail> .DeleteObject(PATH, (invoiceDetail.Id).ToString(), invoiceDetail);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 20
0
        // GET: Invoice/Delete/5
        public ActionResult Delete(int id)
        {
            Invoice invoice = APIConsumer <Invoice> .GetObject(PATH, id.ToString());

            if (invoice.Deleted == false)
            {
                return(View(invoice));
            }

            else
            {
                return(RedirectToAction("DeletedIndex"));
            }
        }
Esempio n. 21
0
        public ActionResult Edit(ProductPrice productPrice)
        {
            try
            {
                // TODO: Add update logic here
                APIConsumer <Models.Webshop.ProductPrice> .EditObject(PATH, productPrice.Id.ToString(), productPrice);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 22
0
        public ActionResult Create(ProductPrice productPrice)
        {
            try
            {
                // TODO: Add insert logic here
                APIConsumer <Models.Webshop.ProductPrice> .AddObject(PATH, productPrice);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 23
0
        public ActionResult Create(InvoiceDetail invoiceDetail)
        {
            try
            {
                // TODO: Add insert logic here
                APIConsumer <Models.Webshop.InvoiceDetail> .AddObject(PATH, invoiceDetail);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 24
0
        public ActionResult Edit(Course course)
        {
            try
            {
                string PId = Request.Form["products"];
                course.ProductId = int.Parse(PId);
                APIConsumer <Models.Webshop.Course> .EditObject("course", course.Id.ToString(), course);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 25
0
        public ActionResult Delete(Invoice invoice)
        {
            try
            {
                // TODO: Add delete logic here
                invoice = APIConsumer <Invoice> .GetObject(PATH, (invoice.Id).ToString());

                invoice.Deleted = true;
                APIConsumer <Models.Webshop.Invoice> .EditObject(PATH, invoice.Id.ToString(), invoice);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 26
0
    public static SqlInt32 APICaller_WebMethod(SqlString httpMethod, SqlString URL, SqlString JsonBody)
    {
        SqlInt32 ExecutionResult = APIConsumer.DEFAULT_EXECUTION_RESULT;

        try
        {
            string Result = APIConsumer.WebMethod(httpMethod.ToString(), URL.ToString(), JsonBody.ToString());

            Helper.SendResultValue(APIConsumer.DEFAULT_COLUMN_RESULT, Result);
        }
        catch (Exception ex)
        {
            Helper.SendResultValue(APIConsumer.DEFAULT_COLUMN_ERROR, ex.Message.ToString());
            ExecutionResult = APIConsumer.FAILED_EXECUTION_RESULT;
        }
        return(ExecutionResult);
    }
Esempio n. 27
0
        // GET: MyOrder
        public ActionResult Details(int id)
        {
            orderDetails = new List <ShoppingCart>();
            decimal total = 0;

            foreach (Invoice item in invoices)
            {
                if (item.Email == user.Email)
                {
                    foreach (InvoiceDetail detail in details)
                    {
                        if (detail.InvoiceId == id)
                        {
                            if (detail.ProductId != 0)
                            {
                                Product products =
                                    APIConsumer <Product> .GetObject("product", detail.ProductId.ToString());

                                total += (products.Price * detail.Pieces);
                                orderDetails.Add(new ShoppingCart()
                                {
                                    Product = products, Quantity = detail.Pieces
                                });
                            }

                            if (detail.CourseId != 0)
                            {
                                Course courses = APIConsumer <Course> .GetObject("course", detail.CourseId.ToString());

                                total += (courses.Price * detail.Pieces);
                                orderDetails.Add(new ShoppingCart()
                                {
                                    Course = courses, Quantity = detail.Pieces
                                });
                            }
                        }
                    }

                    ViewBag.total = total;
                    break;
                }
            }

            return(View(orderDetails));
        }
        private async Task SendRecipeAsync()
        {
            Task task;

            if (EditMode)
            {
                task = APIConsumer.UpdateRecipeAsync(new UpdateRecipeDto()
                {
                    Title       = Title,
                    Description = Description,
                    RecipeID    = Recipe.RecipeID
                });
            }
            else
            {
                task = APIConsumer.SendNewRecipeAsync(new NewRecipeDto()
                {
                    Title              = Title,
                    Description        = Description,
                    ParentAncestryPath = Recipe?.AncestryPath
                });
            }

            await task;

            if (task.IsCompletedSuccessfully && !EditMode)
            {
                if (Recipe is null)
                {
                    RootLevelUpdated?.Invoke(null, null);
                }
                else
                {
                    Recipe.LoadChildrenCommand.Execute(null);
                }
            }
            else if (task.IsCompletedSuccessfully && EditMode)
            {
                Recipe.Title       = Title;
                Recipe.Description = Description;
                EditMode           = false;
            }

            CloseEditorCommand.Execute(null);
        }
    public static SqlInt32 APICaller_GET_JsonBody_Header(SqlString URL, SqlString Headers, SqlString JsonBody)
    {
        SqlInt32 ExecutionResult = APIConsumer.DEFAULT_EXECUTION_RESULT;

        try
        {
            string Result = APIConsumer.GETMethod_Headers(URL.ToString(), JsonBody.ToString(), Headers.ToString());

            Helper.SendResultValue(APIConsumer.DEFAULT_COLUMN_RESULT, Result);
        }
        catch (Exception ex)
        {
            Helper.SendResultValue(APIConsumer.DEFAULT_COLUMN_ERROR, ex.Message.ToString());
            ExecutionResult = APIConsumer.FAILED_EXECUTION_RESULT;
        }

        return(ExecutionResult);
    }
    public static SqlInt32 APICaller_GET_Auth(SqlString URL, SqlString Authorization)
    {
        SqlInt32 ExecutionResult = APIConsumer.DEFAULT_EXECUTION_RESULT;

        try
        {
            string Result = APIConsumer.GETMethod(URL.ToString(), Authorization.ToString());

            Helper.SendResultValue(APIConsumer.DEFAULT_COLUMN_RESULT, Result);
        }
        catch (Exception ex)
        {
            Helper.SendResultValue(APIConsumer.DEFAULT_COLUMN_ERROR, ex.Message.ToString());
            ExecutionResult = APIConsumer.FAILED_EXECUTION_RESULT;
        }

        return(ExecutionResult);
    }