Ejemplo n.º 1
0
        public async Task<ActionResult> Index(string customerId) {
            ListResponse<SubscriptionResponse> subscriptions = await this._mollieClient.GetSubscriptionListAsync(customerId);
            SubscriptionListViewModel viewModel = new SubscriptionListViewModel() {
                CustomerId = customerId,
                Subscriptions = subscriptions.Data
            };

            return this.View(viewModel);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Index(string customerId)
        {
            ListResponse <SubscriptionResponse> subscriptions = await this._subscriptionClient.GetSubscriptionListAsync(customerId);

            SubscriptionListViewModel viewModel = new SubscriptionListViewModel()
            {
                CustomerId    = customerId,
                Subscriptions = subscriptions.Data
            };

            return(this.View(viewModel));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create(SubscriptionForm subscription)
        {
            subscription.AddedDate = DateTime.Now;
            await _subscriptionService.Create(subscription);

            var viewModel = new SubscriptionListViewModel()
            {
                VirtualAccountId = subscription.VirtualAccountId,
                Subscriptions    = await _subscriptionService.GetAll(subscription.VirtualAccountId)
            };

            return(PartialView("_SubscriptionList", viewModel));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Delete(int id)
        {
            var subscription = await _subscriptionService.Get(id);

            await _subscriptionService.Delete(id);

            var viewModel = new SubscriptionListViewModel()
            {
                VirtualAccountId = subscription.VirtualAccountId,
                Subscriptions    = await _subscriptionService.GetAll(subscription.VirtualAccountId)
            };

            return(PartialView("_SubscriptionList", viewModel));
        }
        public ActionResult SearchSubscriptionResult(SearchSubscriptionModel model)
        {
            SubscriptionListViewModel returnModel = new SubscriptionListViewModel();
            var response = AsyncHelpers.RunSync <JObject>(() => ApiCall.CallApi("api/Subscriptions/SearchSubscriptions", User, null, true, false, null, "SubscriptionId=" + model.SubscriptionId, "BoxId=" + model.BoxId + "&UserId=" + model.UserId));

            if (response == null || response is Error)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, (response as Error).ErrorMessage));
            }
            else
            {
                returnModel = response.GetValue("Result").ToObject <SubscriptionListViewModel>();
            }

            returnModel.SetSharedData(User);

            if (returnModel.is_detail)
            {
                return(View("Subscription", returnModel));
            }


            return(PartialView("_SearchSubscriptionResult", returnModel));
        }
Ejemplo n.º 6
0
        public async Task <IHttpActionResult> SearchSubscriptions(int?SubscriptionId, int?BoxId, int?UserId)
        {
            try
            {
                using (SkriblContext ctx = new SkriblContext())
                {
                    SubscriptionListViewModel returnModel = new SubscriptionListViewModel();
                    var query = @"select 
                                UserSubscriptions.Id,
                                UserSubscriptions.User_Id,
                                UserSubscriptions.SubscriptionDate,
                                UserSubscriptions.ExpiryDate,
                                UserSubscriptions.Box_Id,
                                UserSubscriptions.Type,
                                UserSubscriptions.Status,
								UserSubscriptions.ActivationCode,
                                Boxes.Name,
                                Boxes.BoxCategory_Id,
                                Boxes.Price,
                                Users.FullName,
                                Users.ProfilePictureUrl,
								Users.Email,
								Users.Phone
                                from UserSubscriptions
                                join Boxes on Boxes.Id = UserSubscriptions.Box_Id
                                join Users on Users.ID = UserSubscriptions.User_Id  ";

                    if (BoxId.HasValue && UserId.HasValue)
                    {
                        query += @"Where UserSubscriptions.User_Id=" + UserId + " AND UserSubscriptions.Box_Id=" + BoxId + "";
                    }
                    else if (BoxId.HasValue)
                    {
                        query += @"Where UserSubscriptions.Box_Id=" + BoxId + "";
                    }
                    else if (UserId.HasValue)
                    {
                        query += @"Where UserSubscriptions.User_Id=" + UserId + "";
                    }
                    else if (SubscriptionId.HasValue)
                    {
                        query += @" Where UserSubscriptions.Id=" + SubscriptionId + "";
                        returnModel.is_detail = true;
                    }
                    else
                    {
                    }
                    query += @" AND  Boxes.IsDeleted=0";
                    returnModel.Subscriptions = ctx.Database.SqlQuery <AdminSubscriptionViewModel>(query).ToList();

                    // dont need to exe for each of no data found and to prevent any other kind of exception
                    if (returnModel.Subscriptions != null)
                    {
                        foreach (var subscription in returnModel.Subscriptions)
                        {
                            subscription.BoxCategoryName = Utility.GetBoxCategoryName(subscription.BoxCategory_Id);
                        }
                    }

                    return(Ok(new CustomResponse <SubscriptionListViewModel>
                    {
                        Message = Global.ResponseMessages.Success,
                        StatusCode = (int)HttpStatusCode.OK,
                        Result = returnModel
                    }));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(Utility.LogError(ex)));
            }
        }
Ejemplo n.º 7
0
 public MainPage()
 {
     InitializeComponent();
     vm = Resources["vm"] as SubscriptionListViewModel;
 }