Inheritance: BaseModel
        public void UpdateSuite(SuiteModel suiteModel)
        {
            if (suiteModel == null) return;

            using (var unitOfWork = new UnitOfWork(_connectionString))
            {
                bool userAuthorized = UserAuthorizedToAccessSuite(unitOfWork, suiteModel.UserId, suiteModel.SuiteId,
                    new[] {RoleType.Admin});
                if (!userAuthorized)
                    throw new UnauthorizedUserException("User does not have enough privileges to perform this action");

                Suite suiteInDB = unitOfWork.Context.Suites.FirstOrDefault(x => x.SuiteId == suiteModel.SuiteId);

                if (suiteInDB == null)
                    throw new UnauthorizedUserException("User does not have enough privileges to perform this action");

                suiteInDB.IsActive = suiteModel.IsActive;
                suiteInDB.PrivateKey = suiteModel.PrivateKey;
                suiteInDB.SuiteName = suiteModel.SuiteName;
                suiteInDB.UsesSysEncryption = suiteModel.UsesSysEncryption;

                unitOfWork.Update(suiteInDB);

                //unitOfWork.Update<Application, ApplicationModel>(suiteInDB.Applications,
                //    suiteModel.Applications,
                //    application => application.ApplicationId,
                //    userModel => userModel.ApplicationId.GetValueOrDefault(-1),
                //    userModel =>
                //    {
                //        var dbObject = userModel.ToNewDbObject();

                //        dbObject.SuiteId = suiteInDB.SuiteId;
                //        dbObject.IsActive = true;
                //        return dbObject;
                //    });
            }
        }
        public bool DeleteSuite(SuiteModel suiteModel)
        {
            if (suiteModel == null) return false;

            using (var unitOfWork = new UnitOfWork(_connectionString))
            {
                var userSuitesInDB =
                    unitOfWork.Context.SuiteUsers.FirstOrDefault(
                        x => x.UserId == suiteModel.UserId && x.SuiteId == suiteModel.SuiteId);
                if (userSuitesInDB == null)
                    throw new UnauthorizedUserException(
                        "Invalid SuiteId or User does not have enough privileges to perform this action");

                unitOfWork.Delete(userSuitesInDB);

                return true;
                //TODO: Validate if all mappings etc get deleted too.
            }
        }
        public SuiteModel GetSuite(long loggedInUserId, long suiteId)
        {
            using (var unitOfWork = new UnitOfWork(_connectionString))
            {
                // get suites-id of a user
                bool userAuthorized = UserAuthorizedToAccessSuite(unitOfWork, loggedInUserId, suiteId,
                    new[] {RoleType.Admin, RoleType.ReadOnly});
                if (!userAuthorized)
                    throw new UnauthorizedUserException("User does not have enough privileges to perform this action");

                // get suite from suite-id
                var suitesInDB = unitOfWork.Context.Suites.FirstOrDefault(x => x.SuiteId == suiteId);

                if (suitesInDB != null)
                {
                    var suiteModels = new SuiteModel
                    {
                        IsActive = suitesInDB.IsActive,
                        PrivateKey = suitesInDB.PrivateKey,
                        PublicKey = suitesInDB.PublicKey,
                        SuiteId = suitesInDB.SuiteId,
                        SuiteName = suitesInDB.SuiteName,
                        UserId = loggedInUserId,
                        UsesSysEncryption = suitesInDB.UsesSysEncryption,
                        Applications = suitesInDB.Applications.ToModel(),
                        Environments = suitesInDB.Environments.ToModel(),
                        Regions = suitesInDB.Regions.ToModel(),
                        Servers = suitesInDB.Servers.ToModel(),
                        Users = suitesInDB.SuiteUsers.ToModel()
                    };

                    return suiteModels;
                }

                // If it has come here that means suite id is not existing, which is -ve case
                return default(SuiteModel);
            }
        }