public static bool UpdateUserSubscription(int userSubscriptionID, bool subscribed)
    {
        MyFlixEntities db = new MyFlixEntities();

        UserSubscription us = db.UserSubscriptions.FirstOrDefault(u => u.UserSubscriptionID == userSubscriptionID);

        if (us != null)
        {
            if (subscribed)
            {
                us.SubscribedDate = DateTime.UtcNow;
            }
            else
            {
                us.SubscribedDate = null;
            }

            db.UserSubscriptions.Attach(us);
            db.Entry(us).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(true);
        }

        return(false);
    }
Exemplo n.º 2
0
    public static bool Login(string email, string password)
    {
        MyFlixEntities db = new MyFlixEntities();

        User user = db.Users.FirstOrDefault(u => email.ToLower().Equals(email) && u.Password.Equals(password));

        SessionHandler.UserID = user != null ? user.UserID : 0;

        return(user != null);
    }
    public static bool LinkSubscription(int serviceProdiverID)
    {
        MyFlixEntities db = new MyFlixEntities();

        if (db.UserSubscriptions.Any(u => u.UserID == SessionHandler.UserID && u.ServiceProviderID == serviceProdiverID))
        {
            return(false);
        }
        else
        {
            UserSubscription us = new UserSubscription {
                UserID = SessionHandler.UserID, ServiceProviderID = serviceProdiverID, NewPayment = 9.99M, OldPayment = 10.99M, SubscribedDate = DateTime.UtcNow
            };
            db.UserSubscriptions.Add(us);
            db.SaveChanges();

            return(true);
        }
    }
Exemplo n.º 4
0
    public static bool CreateAccount(string email, string password)
    {
        MyFlixEntities db = new MyFlixEntities();

        if (db.Users.Any(u => u.EmailAddress.ToLower().Equals(email.ToLower())))
        {
            return(false);
        }
        else
        {
            User user = new User
            {
                EmailAddress     = email,
                Password         = password,
                DateCreated      = DateTime.UtcNow,
                IsActive         = true,
                ProfilePhotoPath = "",
            };
            db.Users.Add(user);
            db.SaveChanges();

            return(true);
        }
    }
Exemplo n.º 5
0
    public static User GetUser()
    {
        MyFlixEntities db = new MyFlixEntities();

        return(db.Users.FirstOrDefault(u => u.UserID == SessionHandler.UserID));
    }
    public static List <view_UserSubscription> GetUserSubscriptions()
    {
        MyFlixEntities db = new MyFlixEntities();

        return(db.view_UserSubscription.Where(v => v.UserID.Equals(SessionHandler.UserID)).ToList());
    }
Exemplo n.º 7
0
    public List <view_UserSubscription> GetUserSubscriptions(int userID)
    {
        MyFlixEntities db = new MyFlixEntities();

        return(db.view_UserSubscription.Where(v => v.UserID.Equals(userID)).ToList());
    }