public bool UseResource(int UserId, int SubcriptionId, int ResourceId)
        {
            using (Context context = new Context())
            {
                bool hasValidVoucher;
                try
                {
                    var userVoucher    = context.couchers.Where(x => x.user.ID == UserId && x.Used == false && x.ExpiryDate >= DateTime.Now);
                    var firstOrDefault = userVoucher.FirstOrDefault();
                    if (firstOrDefault != null)
                    {
                        MethodBank mb = new MethodBank();
                        mb.MarkVoucherAsDone(firstOrDefault.ID);
                        return(true);
                    }
                    hasValidVoucher = false;
                }
                catch
                {
                    hasValidVoucher = false;
                }

                if (!hasValidVoucher)
                {
                    try
                    {
                        var dailyLimit = context.userSubcriptions.FirstOrDefault(x => x.SubcriptionID.ID == SubcriptionId && x.UserID.ID == UserId).DailyLimit;
                        //var dailyLimit = context.userSubcriptions.FirstOrDefault(u => u.UserID.ID == UserId).DailyLimit;
                        int userCredit;
                        try
                        {
                            userCredit = context.credit.Where(x => x.user.ID == UserId && x.Date == DateTime.Now.Date).Sum(x => x.CreditUsed);
                        }
                        catch
                        {
                            userCredit = 0;
                        }
                        var resourceFee = context.resource.Single(x => x.ID == ResourceId).ActivationFee;

                        if (userCredit <= dailyLimit)
                        {
                            DataBank db = new DataBank();
                            db.AddCredit(UserId, resourceFee, SubcriptionId);
                            return(true);
                        }
                        return(false);
                    }
                    catch
                    {
                        return(false);
                    }
                }
            }
            return(false);
        }
        public Dashboard GetDashboard(int userId)
        {
            Context    context = new Context();
            MethodBank mb      = new MethodBank();
            Dashboard  dash    = new Dashboard();

            dash.Resources     = mb.GetNumberOfResources();
            dash.Subscriptions = mb.GetNumberOfSubcriptions();
            dash.Users         = mb.GetNumberOfUsers();
            dash.Vouchers      = mb.GetNumberOfVouchers();
            dash.FirstName     = context.users.Where(x => x.ID == userId).FirstOrDefault().FirstName;
            dash.LastName      = context.users.Where(x => x.ID == userId).FirstOrDefault().LastName;
            return(dash);
        }