예제 #1
0
        protected async Task AddNewCoupon()
        {
            var result = await RegisteredFunction.InvokeAsync <bool>("validateCoupon");

            if (result)
            {
                if (NewCoupon.Type == (int)Consts.CouponType.Date)
                {
                    CouponDateStr = MegaService.Util.GetInput <string>("#new-coupon-date");
                    var parseResult = DateTime.TryParse(CouponDateStr, out var dateTime);
                    if (!parseResult)
                    {
                        return;
                    }
                    NewCoupon.DateExpired = dateTime;
                }
                NewCoupon.Id = -1; //signify the coupon as not saved yet
                Product.Coupons.Add(NewCoupon);

                // TODO: SAVE STUFFIE TO SERVER HERE
                var saveResult = await MegaService.Fetcher.Fetch("/api/product/AddCoupon/", new
                {
                    Product.Id,
                    Coupon = NewCoupon
                });

                var saveBool = saveResult["Result"].ToObject <bool>();

                Toastr(saveBool);
                NewCoupon = null;
                StateHasChanged();
            }
        }
예제 #2
0
        public static async Task <string> GetFileData(string fileInputRef)
        {
            return((await RegisteredFunction.InvokeAsync <StringHolder>("getFileData", fileInputRef)).Content);
            //ConsoleLog("C# just received byte[] : " + base64fileContent.Length);
            //string res = null;


            //return res;
        }
예제 #3
0
 public static Task <object> WriteText(string text)
 {
     return(RegisteredFunction.InvokeAsync <object>("BlazorClipboard.WriteText", text));
 }
예제 #4
0
 private void Confirm(string title, string text, string mode)
 {
     RegisteredFunction.InvokeAsync <bool>("sweetAlertConfirm", title, text, mode, true);
 }
예제 #5
0
 private void Alert(string title, string text, string mode, bool multi)
 {
     RegisteredFunction.InvokeAsync <bool>("sweetAlert", title, text, mode);
 }
예제 #6
0
 public Task <TResult> InvokeAsync <TResult>(string methodName, params object[] args) =>
 RegisteredFunction.InvokeAsync <TResult>(INVOKE_WITH_RESULT_ASYNC_METHOD, this.InternalConnectionId, methodName, args);
예제 #7
0
 public Task InvokeAsync(string methodName, params object[] args) =>
 RegisteredFunction.InvokeAsync <object>(INVOKE_ASYNC_METHOD, this.InternalConnectionId, methodName, args);
예제 #8
0
 public Task StopAsync() => RegisteredFunction.InvokeAsync <object>(STOP_CONNECTION_METHOD, this.InternalConnectionId);